  var size:int;
  var errorCheck:Boolean=false;
  var datasizes:Vector.<int> = new Vector.<int>(3,true);
  datasizes[0] = 2;
  datasizes[1] = 8;
  datasizes[2] = 12;

  var machff:Number = 0.7; /* Inflow mach number */

  var secondOrderDamping:Number = 1.0;

  var fourthOrderDamping:Number = 1.0;

  var ntime:int = 1; /* 0 = local timestep, 1 = time accurate */

  var scale:int; /* Refine input grid by this factor */

  var error:Number;

  var a:Vector.<Vector.<Number>>; /*double[][]; Grid cell area */

  var deltat:Vector.<Vector.<Number>>; /*double[][];  Timestep */

  var opg:Vector.<Vector.<Number>>, pg:Vector.<Vector.<Number>>, pg1:Vector.<Vector.<Number>>; /*double [][] Pressure */

  var sxi:Vector.<Vector.<Number>>, seta:Vector.<Vector.<Number>>; /*double[][]*/

  var tg:Vector.<Vector.<Number>>, tg1:Vector.<Vector.<Number>>; /*double[][] Temperature */

  var xnode:Vector.<Vector.<Number>>, ynode:Vector.<Vector.<Number>>; /*double[][] Storage of node coordinates */

  var oldval:Vector.<Vector.<Vector.<Number>>>, newval:Vector.<Vector.<Vector.<Number>>>; /*[][][] Tepmoray arrays for interpolation */

  var cff:Number, uff:Number, vff:Number, pff:Number, rhoff:Number, tff:Number, jplusff:Number, jminusff:Number; /*double*/

  /* Far field values */
  var datamax:Number, datamin:Number; /*double*/

  var iter:int = 100; /*int Number of iterations */

  var imax:int, jmax:int; /*int Number of nodes in x and y direction */

  var imaxin:int, jmaxin:int; /* Number of nodes in x and y direction in unscaled data */

  var nf:int = 6; /* Number of fields in data file */

  var d:Vector.<Vector.<Statevector>>; /*Statevectyor[][] Damping coefficients */

  var f:Vector.<Vector.<Statevector>>, g:Vector.<Vector.<Statevector>>; /*Statevector[][] Flux Vectors */

  var r:Vector.<Vector.<Statevector>>, ug1:Vector.<Vector.<Statevector>>; /*Statevector[][]*/

  var ug:Vector.<Vector.<Statevector>>; /*Statevector[][] Storage of data */

  var Cp:Number = 1004.5; /*double specific heat, const pres. */

  var Cv:Number = 717.5; /*double specific heat, const vol. */

  var gamma:Number = 1.4; /*double Ratio of specific heats */

  var rgas:Number = 287.0; /*double Gas Constant */

  var fourthOrderNormalizer:Number = 0.02; /*double Damping coefficients */

  var secondOrderNormalizer:Number = 0.02; /*double */
  
  
  function JGFsetsize(sizel:int):void {
    size = sizel;
  }

  function JGFinitialise():void {
      initialise();
  }

  function JGFapplication():void {
    //print("entering JGFapplication");
    runiters();
  }

  function JGFvalidate():Boolean {
    var refval:Vector.<Number> = new Vector.<Number>(3,true);
    refval[0] = 0.0006404115803224407; // 0.0013717684673271995
    refval[1] = 0.0033831416599344965;
    refval[2] = 0.006812543658280322;
    var dev:Number = Math.abs(error - refval[size]);
    if (dev > 1.0e-12) {
      print("Validation failed");
      print("Computed RMS pressure error = " + error);
      print("Reference value             = " + refval[size]);
      return false;
    }else
    {
      print("Validation passed");
      return true;
    }
  }

  function JGFtidyup():void {
    a = null;
    deltat = null;
    opg = null;
    pg = null;
    pg1 = null;
    sxi = null;
    seta = null;
    tg = null;
    tg1 = null;
    xnode = null;
    ynode = null;
    d = null;
    f = null;
    g = null;
    r = null;
    ug1 = null;
    ug = null;
  }

  function JGFrun(size:int):void {
    JGFsetsize(size);
    JGFinitialise();
    JGFapplication();
    JGFvalidate();
    //JGFtidyup();
  }
  function initTripleArray(nf:int,imaxin:int,jmaxin:int):Vector.<Vector.<Vector.<Number>>>
  {
    var mainArray:Vector.<Vector.<Vector.<Number>>>= new Vector.<Vector.<Vector.<Number>>>(nf,true);
    for(var i:int=0;i<nf;i++)
    {
      mainArray[i] = new Vector.<Vector.<Number>>(imaxin,true);
      for(var j:int=0;j<imaxin;j++)
      {
        mainArray[i][j] = new Vector.<Number>(jmaxin,true);
      }
    }
    return mainArray;
  }
  function initDoubleArray(size1:int, size2:int):Vector.<Vector.<Number>>
  {
    var mainArray:Vector.<Vector.<Number>> = new Vector.<Vector.<Number>>(size1,true);
    for(var i:int=0;i<size1;i++)
    {
      mainArray[i] = new Vector.<Number>(size2,true);
    }
    return mainArray;
  }
  
    function initDoubleStatevectorArray(size1:int, size2:int):Vector.<Vector.<Statevector>>
  {
    var mainArray:Vector.<Vector.<Statevector>> = new Vector.<Vector.<Statevector>>(size1,true);
    for(var i:int=0;i<size1;i++)
    {
      mainArray[i] = new Vector.<Statevector>(size2,true);
    }
    return mainArray;
  }
  
  
  function initialise():void {
    //Alex: For some reason none of the string functions like split work if string is global. So I just made it local since it's used only in one function
    var data = "33\t9\t"
                        + "-1.00000000000000000000\t0.00000000000000000000\t1.01633253274924300000\t0.69594989322316947000\t0.00012423415727022292\t2.06440385282092590000\t"
                        + "-1.00000000000000000000\t0.05183200000000000300\t1.01623485123881880000\t0.69604847097630540000\t0.00048005265056625637\t2.06427196842501550000\t"
                        + "-1.00000000000000000000\t0.11069800000000000000\t1.01582974068940460000\t0.69619432160505179000\t0.00091147084760581437\t2.06347825676689790000\t"
                        + "-1.00000000000000000000\t0.17881400000000000000\t1.01491997162403070000\t0.69636927544076910000\t0.00122984966200296620\t2.06156411952970900000\t"
                        + "-1.00000000000000000000\t0.25963700000000001000\t1.01372792777759630000\t0.69678264615202623000\t0.00185618756502228330\t2.05919893807544740000\t"
                        + "-1.00000000000000000000\t0.35902200000000001000\t1.01144980098635930000\t0.69718950150466819000\t0.00226509766443798100\t2.05440670569913310000\t"
                        + "-1.00000000000000000000\t0.48811700000000002000\t1.00672135520523540000\t0.69755064504050002000\t0.00124338328625856610\t2.04407851533280560000\t"
                        + "-1.00000000000000000000\t0.67264100000000004000\t1.00214387014327920000\t0.69829226247499421000\t-0.00000102359133096300\t2.03438133257328380000\t"
                        + "-1.00000000000000000000\t1.00000000000000000000\t1.00174746698327420000\t0.69846869929253541000\t0.00004317668610895152\t2.03361412607980930000\t"
                        + "-0.70926999999999996000\t0.00000000000000000000\t1.05796345195146110000\t0.67725973876036194000\t0.00111046177346119750\t2.15179413372528260000\t"
                        + "-0.70926999999999996000\t0.05183200000000000300\t1.05751012853604380000\t0.67751255648185649000\t0.00352422860316615370\t2.15085529179139460000\t"
                        + "-0.70926999999999996000\t0.11069800000000000000\t1.05653342262020080000\t0.67806951486219902000\t0.00633144787309188920\t2.14885385803719230000\t"
                        + "-0.70926999999999996000\t0.17881400000000000000\t1.05460177495404680000\t0.67889663564238178000\t0.00917498247914409240\t2.14472982195419390000\t"
                        + "-0.70926999999999996000\t0.25963700000000001000\t1.05151375825685280000\t0.68032924964044883000\t0.01218465739153269700\t2.13820234778612050000\t"
                        + "-0.70926999999999996000\t0.35902200000000001000\t1.04815203675830860000\t0.68346070604264331000\t0.01621044744122422300\t2.13203953290066610000\t"
                        + "-0.70926999999999996000\t0.48811700000000002000\t1.03928424329118710000\t0.68869340282605673000\t0.01519569852782632700\t2.11416201040839400000\t"
                        + "-0.70926999999999996000\t0.67264100000000004000\t1.02510970125826220000\t0.69315367854403853000\t0.00483253095402537070\t2.08352628034512490000\t"
                        + "-0.70926999999999996000\t1.00000000000000000000\t1.02267599407972230000\t0.69395980206853358000\t-0.00467040130806209430\t2.07839923908534980000\t"
                        + "-0.50896200000000003000\t0.00000000000000000000\t1.09224263458651420000\t0.65697903931215418000\t0.00249258845019721110\t2.22067164018384760000\t"
                        + "-0.50896200000000003000\t0.05183200000000000300\t1.09145264397989570000\t0.65746285713917130000\t0.00763651469101566010\t2.21900852546898530000\t"
                        + "-0.50896200000000003000\t0.11069800000000000000\t1.08993816434874220000\t0.65860359136561897000\t0.01325513708210598500\t2.21597254409167730000\t"
                        + "-0.50896200000000003000\t0.17881400000000000000\t1.08790242141573270000\t0.66037800496900889000\t0.01913070058243483300\t2.21205555009273920000\t"
                        + "-0.50896200000000003000\t0.25963700000000001000\t1.08418148726586570000\t0.66289092022265084000\t0.02378396865119880600\t2.20445879209686210000\t"
                        + "-0.50896200000000003000\t0.35902200000000001000\t1.08310199517923930000\t0.66849688587878886000\t0.03012032539165209600\t2.20510211285278990000\t"
                        + "-0.50896200000000003000\t0.48811700000000002000\t1.07994746678201010000\t0.67753190993651657000\t0.03040154609088103300\t2.20285450483177940000\t"
                        + "-0.50896200000000003000\t0.67264100000000004000\t1.06628429847673980000\t0.68360585994055478000\t0.01136336656438763500\t2.17360960365281120000\t"
                        + "-0.50896200000000003000\t1.00000000000000000000\t1.06215336639509550000\t0.68504835900528005000\t-0.01131596936490563200\t2.16472718078217060000\t"
                        + "-0.35597699999999999000\t0.00000000000000000000\t1.09961508123696540000\t0.64163470959846702000\t0.00413284145327335110\t2.22840276753115420000\t"
                        + "-0.35597699999999999000\t0.05183200000000000300\t1.09854844306001740000\t0.64311141571139496000\t0.01203672248031600900\t2.22695964870631300000\t"
                        + "-0.35597699999999999000\t0.11069800000000000000\t1.09634815054222460000\t0.64584465837108362000\t0.01962413051003893100\t2.22327863667056520000\t"
                        + "-0.35597699999999999000\t0.17881400000000000000\t1.09472054989934040000\t0.65010974515993392000\t0.02715458885717425200\t2.22178034596011290000\t"
                        + "-0.35597699999999999000\t0.25963700000000001000\t1.09197244876150950000\t0.65483743633499769000\t0.03108048884882666200\t2.21773287424267270000\t"
                        + "-0.35597699999999999000\t0.35902200000000001000\t1.09433416013543330000\t0.66230253175522491000\t0.03459245201950703800\t2.22768898973078810000\t"
                        + "-0.35597699999999999000\t0.48811700000000002000\t1.10447666054088600000\t0.67145197436947490000\t0.03542066017566195000\t2.25753711813443880000\t"
                        + "-0.35597699999999999000\t0.67264100000000004000\t1.10550960961960800000\t0.67446108402010074000\t0.01545248136262992700\t2.26151315572051860000\t"
                        + "-0.35597699999999999000\t1.00000000000000000000\t1.10191689509553110000\t0.67584655793540882000\t-0.01580860495147432300\t2.25370585720417750000\t"
                        + "-0.23217499999999999000\t0.00000000000000000000\t1.10780476938693970000\t0.63326503745992113000\t0.01001625140154585900\t2.24246484617440830000\t"
                        + "-0.23217499999999999000\t0.05183200000000000300\t1.10149411265350630000\t0.63579576365184853000\t0.02467174488416347100\t2.22918462894400000000\t"
                        + "-0.23217499999999999000\t0.11069800000000000000\t1.09601089105427230000\t0.64072620603402897000\t0.03222249907475073500\t2.21925040056340660000\t"
                        + "-0.23217499999999999000\t0.17881400000000000000\t1.09144390502951370000\t0.64811110090497182000\t0.03813159404206482900\t2.21261676122838890000\t"
                        + "-0.23217499999999999000\t0.25963700000000001000\t1.08794910661530490000\t0.65599066300055775000\t0.03814394724805182700\t2.20860476534821440000\t"
                        + "-0.23217499999999999000\t0.35902200000000001000\t1.08947082387554550000\t0.66536791336352696000\t0.03389354166197270500\t2.21755339364647290000\t"
                        + "-0.23217499999999999000\t0.48811700000000002000\t1.10637106737147150000\t0.67387399119556846000\t0.03151546722824204900\t2.26330832912699000000\t"
                        + "-0.23217499999999999000\t0.67264100000000004000\t1.12141086706878750000\t0.67346477903889235000\t0.01597405424404546900\t2.29923653214680090000\t"
                        + "-0.23217499999999999000\t1.00000000000000000000\t1.12005230534746620000\t0.67411014296907001000\t-0.01667682615648040700\t2.29634311499993340000\t"
                        + "-0.12818499999999999000\t0.00000000000000000000\t1.11877183076426730000\t0.57490282011781846000\t0.01866798003599267100\t2.23900836588505750000\t"
                        + "-0.12818499999999999000\t0.05183200000000000300\t1.10659757644166310000\t0.61023062510783010000\t0.04376703018594321800\t2.22673165827400950000\t"
                        + "-0.12818499999999999000\t0.11069800000000000000\t1.09777803096620710000\t0.62908819972578300000\t0.05118528905599666800\t2.21635383252731180000\t"
                        + "-0.12818499999999999000\t0.17881400000000000000\t1.08915017665832710000\t0.64494887943985990000\t0.05314930161925994500\t2.20515768919902920000\t"
                        + "-0.12818499999999999000\t0.25963700000000001000\t1.08420844907632550000\t0.65852485607551314000\t0.04780753532059321000\t2.20121389369962280000\t"
                        + "-0.12818499999999999000\t0.35902200000000001000\t1.08251612252566500000\t0.67088996921907118000\t0.03517491630707601800\t2.20420827345563630000\t"
                        + "-0.12818499999999999000\t0.48811700000000002000\t1.09656136792761760000\t0.68055735585494626000\t0.02690444830506533500\t2.24367282232237650000\t"
                        + "-0.12818499999999999000\t0.67264100000000004000\t1.11527583653773690000\t0.68037148454825025000\t0.01497627572449967100\t2.28849995695042760000\t"
                        + "-0.12818499999999999000\t1.00000000000000000000\t1.11579951804086020000\t0.68038193092447241000\t-0.01576811665569551400\t2.28979392889044050000\t"
                        + "-0.03853299999999999800\t0.00000000000000000000\t1.15797252050243540000\t0.53866998389067799000\t0.08827217724448255300\t2.32142876671935160000\t"
                        + "-0.03853299999999999800\t0.05183200000000000300\t1.11332310893114330000\t0.59284314386577808000\t0.10936552494826596000\t2.23844841062516100000\t"
                        + "-0.03853299999999999800\t0.11069800000000000000\t1.10202612879058210000\t0.62929370317256772000\t0.09173108707983901300\t2.22922895045024250000\t"
                        + "-0.03853299999999999800\t0.17881400000000000000\t1.08627520282973870000\t0.65094211489397635000\t0.07882949415340172200\t2.20330236714907370000\t"
                        + "-0.03853299999999999800\t0.25963700000000001000\t1.07951326560824020000\t0.66723175603440632000\t0.06132507509941036200\t2.19599844841337080000\t"
                        + "-0.03853299999999999800\t0.35902200000000001000\t1.07558692618880310000\t0.67987735315588671000\t0.03950180032807805400\t2.19353204676354440000\t"
                        + "-0.03853299999999999800\t0.48811700000000002000\t1.08493981475182790000\t0.68889664437554543000\t0.02483876981237407100\t2.22107042422938820000\t"
                        + "-0.03853299999999999800\t0.67264100000000004000\t1.10222319720784930000\t0.68934246801538435000\t0.01398972620397986000\t2.26253703015229890000\t"
                        + "-0.03853299999999999800\t1.00000000000000000000\t1.10356521996582970000\t0.68913673268003506000\t-0.01473987180995553800\t2.26565840916990610000\t"
                        + "0.04026099999999999800\t0.01599300000000000000\t1.10869590212957880000\t0.60337215587318771000\t0.16280148278131434000\t2.24893971312382760000\t"
                        + "0.04026099999999999800\t0.06699600000000000000\t1.07210876188135070000\t0.62951962526788696000\t0.15612865242552734000\t2.16911626943324800000\t"
                        + "0.04026099999999999800\t0.12492100000000000000\t1.07363133442858930000\t0.66434768396732446000\t0.11766650232466615000\t2.18587874698278690000\t"
                        + "0.04026099999999999800\t0.19194800000000001000\t1.06251702079552080000\t0.67622630523809835000\t0.09375511921402818200\t2.16422205406828820000\t"
                        + "0.04026099999999999800\t0.27147800000000000000\t1.06225247573480660000\t0.68647788033107005000\t0.06671389754819155600\t2.16785094563094690000\t"
                        + "0.04026099999999999800\t0.36927300000000002000\t1.06192341263424270000\t0.69358686153695992000\t0.03995345199588715800\t2.17021794557562850000\t"
                        + "0.04026099999999999800\t0.49630299999999999000\t1.07191395728369580000\t0.69820195353438619000\t0.02231092314202768800\t2.19615284639389240000\t"
                        + "0.04026099999999999800\t0.67787699999999995000\t1.08993579501272350000\t0.69738595617957544000\t0.01285178210534825400\t2.23820851038716380000\t"
                        + "0.04026099999999999800\t1.00000000000000000000\t1.09167059990119660000\t0.69712985603590705000\t-0.01355847476995183200\t2.24220772240397800000\t"
                        + "0.11054400000000000000\t0.04029200000000000100\t1.01564308667504570000\t0.67965353284580410000\t0.16636392938051639000\t2.07220764218164800000\t"
                        + "0.11054400000000000000\t0.09003500000000000400\t1.01386234212294620000\t0.67789516200530398000\t0.14145842078303336000\t2.06058165385093120000\t"
                        + "0.11054400000000000000\t0.14652999999999999000\t1.02846787889707000000\t0.69988496450976745000\t0.10848242475554633000\t2.10202833072914960000\t"
                        + "0.11054400000000000000\t0.21190100000000001000\t1.03005301032367380000\t0.70164910319035356000\t0.08703975822267048800\t2.10463428200317000000\t"
                        + "0.11054400000000000000\t0.28946800000000000000\t1.03936051814643120000\t0.70565856748801592000\t0.06083220076402304200\t2.12678627033441850000\t"
                        + "0.11054400000000000000\t0.38484800000000002000\t1.04446747439283820000\t0.70711313283068289000\t0.03518987246076288300\t2.13834025486602240000\t"
                        + "0.11054400000000000000\t0.50874100000000000000\t1.05730869150562050000\t0.70710932482476019000\t0.01803678847092847100\t2.16772693673055360000\t"
                        + "0.11054400000000000000\t0.68583099999999997000\t1.07761066442101950000\t0.70465003509083857000\t0.01130125030278132700\t2.21367152704824170000\t"
                        + "0.11054400000000000000\t1.00000000000000000000\t1.07972969685425910000\t0.70434541691899355000\t-0.01196748825869488300\t2.21850904330976960000\t"
                        + "0.17397799999999999000\t0.05845500000000000000\t0.97891959810793205000\t0.71546248953906044000\t0.15496833698063617000\t2.01126564758218820000\t"
                        + "0.17397799999999999000\t0.10725700000000001000\t0.99169390744141217000\t0.70765494646149807000\t0.12305762223205813000\t2.02790377165308520000\t"
                        + "0.17397799999999999000\t0.16268299999999999000\t1.00404784894586880000\t0.72106044903126965000\t0.09743445591950637700\t2.06001150886598210000\t"
                        + "0.17397799999999999000\t0.22681699999999999000\t1.01006577469050600000\t0.71937888465560440000\t0.07724426099022518900\t2.07052137752691000000\t"
                        + "0.17397799999999999000\t0.30291499999999999000\t1.02195108968995840000\t0.72046127567363505000\t0.05304256851361175600\t2.09661496735462860000\t"
                        + "0.17397799999999999000\t0.39649000000000001000\t1.02890160847309460000\t0.71833428171196911000\t0.02912011613940910700\t2.11003295911997090000\t"
                        + "0.17397799999999999000\t0.51803900000000003000\t1.04272323631536130000\t0.71496901275417857000\t0.01314646217629766000\t2.13917686824517880000\t"
                        + "0.17397799999999999000\t0.69177699999999998000\t1.06446334618897830000\t0.71141832457612864000\t0.00951227204015934680\t2.18725155641816690000\t"
                        + "0.17397799999999999000\t1.00000000000000000000\t1.06690399424879940000\t0.71108752981957390000\t-0.01012417549197022900\t2.19277488889220610000\t"
                        + "0.23177900000000001000\t0.07202899999999999600\t0.94438611064577238000\t0.73877092371312136000\t0.13595491365394868000\t1.95115131956350330000\t"
                        + "0.23177900000000001000\t0.12012700000000000000\t0.96700013819978747000\t0.73180506010036694000\t0.10282482800000692000\t1.98853428715253200000\t"
                        + "0.23177900000000001000\t0.17475399999999999000\t0.97878811163166102000\t0.73749670295078640000\t0.08399520817672123700\t2.01486067238799250000\t"
                        + "0.23177900000000001000\t0.23796300000000001000\t0.98999273022109935000\t0.73418124605556279000\t0.06509691716517894400\t2.03552127170242510000\t"
                        + "0.23177900000000001000\t0.31296499999999999000\t1.00437824282230030000\t0.73298653108235545000\t0.04393663935117708700\t2.06547402834463640000\t"
                        + "0.23177900000000001000\t0.40519100000000002000\t1.01356534155597240000\t0.72795577891211549000\t0.02228489388116931100\t2.08183333309974470000\t"
                        + "0.23177900000000001000\t0.52498699999999998000\t1.02837897690066790000\t0.72176738527681261000\t0.00802543201631003220\t2.11096854463419700000\t"
                        + "0.23177900000000001000\t0.69621999999999995000\t1.05126454525022010000\t0.71745281149256290000\t0.00762151542590231920\t2.16060932328436190000\t"
                        + "0.23177900000000001000\t1.00000000000000000000\t1.05393254601846120000\t0.71712214021902621000\t-0.00817531455852247430\t2.16660239816113840000\t"
                        + "0.28486699999999998000\t0.08207599999999999600\t0.91052613009156780000\t0.75509701500143889000\t0.11362674228968718000\t1.89061050627546520000\t"
                        + "0.28486699999999998000\t0.12965299999999999000\t0.94139530311376263000\t0.75114438264518346000\t0.08104015895069316400\t1.94607167591771880000\t"
                        + "0.28486699999999998000\t0.18368799999999999000\t0.95368665860425961000\t0.75050159888486523000\t0.06821263851966571900\t1.96920666620445870000\t"
                        + "0.28486699999999998000\t0.24621299999999999000\t0.96973893613038753000\t0.74649800738635330000\t0.05106233923008296500\t1.99951788609060350000\t"
                        + "0.28486699999999998000\t0.32040299999999999000\t0.98649449417018253000\t0.74350235858896774000\t0.03358090241128704200\t2.03310757647397720000\t"
                        + "0.28486699999999998000\t0.41163100000000002000\t0.99813212564765941000\t0.73619066768260988000\t0.01469416565718445700\t2.05307638994073380000\t"
                        + "0.28486699999999998000\t0.53012999999999999000\t1.01423662859847230000\t0.72759830606934339000\t0.00267014599104141350\t2.08302608458076530000\t"
                        + "0.28486699999999998000\t0.69950900000000005000\t1.03842714756603600000\t0.72268257372173272000\t0.00565756203799700100\t2.13462963913309610000\t"
                        + "0.28486699999999998000\t1.00000000000000000000\t1.04127883291479820000\t0.72236446717123226000\t-0.00615582330375045570\t2.14099230463437400000\t"
                        + "0.33395300000000000000\t0.08935200000000000100\t0.88136672919543979000\t0.76537871642571131000\t0.09060742791957718300\t1.83791259921236370000\t"
                        + "0.33395300000000000000\t0.13655200000000001000\t0.91893617716589504000\t0.76510758189485573000\t0.05912837316733302000\t1.90844001048407600000\t"
                        + "0.33395300000000000000\t0.19015899999999999000\t0.93139159009780792000\t0.75970885717261794000\t0.05164580598331647300\t1.92828285952289580000\t"
                        + "0.33395300000000000000\t0.25218900000000000000\t0.95107713443782027000\t0.75588067316789009000\t0.03636295601053488700\t1.96595890581146620000\t"
                        + "0.33395300000000000000\t0.32579000000000002000\t0.96948668879049382000\t0.75180887174491395000\t0.02262535666411547400\t2.00192449330614730000\t"
                        + "0.33395300000000000000\t0.41629500000000003000\t0.98315753276487605000\t0.74298222982686613000\t0.00665719796123354080\t2.02491164296397400000\t"
                        + "0.33395300000000000000\t0.53385400000000005000\t1.00043303729351510000\t0.73248473439653883000\t-0.00284987374316114300\t2.05562783127500830000\t"
                        + "0.33395300000000000000\t0.70189100000000004000\t1.02593710054782790000\t0.72717497275097309000\t0.00363884249729646550\t2.10928340821999380000\t"
                        + "0.33395300000000000000\t1.00000000000000000000\t1.02894616975380910000\t0.72687079670847099000\t-0.00408466127112979030\t2.11595102962063650000\t"
                        + "0.37959700000000002000\t0.09441199999999999600\t0.85539145803508621000\t0.77160158761724162000\t0.06790230830057748800\t1.79076853584451000000\t"
                        + "0.37959700000000002000\t0.14135000000000000000\t0.89845091789570608000\t0.77555932161320895000\t0.03779776494739912200\t1.87403405199496500000\t"
                        + "0.37959700000000002000\t0.19465900000000000000\t0.91107355470475304000\t0.76665295685510271000\t0.03528625699194398000\t1.89104716623659330000\t"
                        + "0.37959700000000002000\t0.25634400000000002000\t0.93368524732735581000\t0.76324741777833638000\t0.02193568413452788200\t1.93456849262718640000\t"
                        + "0.37959700000000002000\t0.32953700000000002000\t0.95336852990006649000\t0.75837642198105570000\t0.01172036122374116300\t1.97214279915973000000\t"
                        + "0.37959700000000002000\t0.41953800000000002000\t0.96876612002105367000\t0.74847229657712711000\t-0.00143824699933451970\t1.99763160513722270000\t"
                        + "0.37959700000000002000\t0.53644499999999995000\t0.98707847085334210000\t0.73647849352349759000\t-0.00837059182039250930\t2.02900055561440330000\t"
                        + "0.37959700000000002000\t0.70354799999999995000\t1.01383155714645200000\t0.73098721494331775000\t0.00161177178170554940\t2.08465084730945760000\t"
                        + "0.37959700000000002000\t1.00000000000000000000\t1.01697695243399710000\t0.73070351249627830000\t-0.00200847656826816470\t2.09157657286486250000\t"
                        + "0.42225299999999999000\t0.09767299999999999600\t0.83135878610049696000\t0.77466199207757058000\t0.04596167161529404700\t1.74629195918086770000\t"
                        + "0.42225299999999999000\t0.14444199999999999000\t0.87888704410562069000\t0.78244375526981513000\t0.01717325713245707000\t1.84006273645804200000\t"
                        + "0.42225299999999999000\t0.19755900000000001000\t0.89176180705710950000\t0.77096976368785819000\t0.01896282398178425500\t1.85497641910294210000\t"
                        + "0.42225299999999999000\t0.25902199999999997000\t0.91692207772205958000\t0.76846016584945198000\t0.00748574640486719850\t1.90375419615568300000\t"
                        + "0.42225299999999999000\t0.33195100000000000000\t0.93783630647299576000\t0.76335046028004794000\t0.00067551712973560945\t1.94310427171026020000\t"
                        + "0.42225299999999999000\t0.42162800000000000000\t0.95488316159279041000\t0.75287515415637907000\t-0.00964615574754882670\t1.97115231016371070000\t"
                        + "0.42225299999999999000\t0.53811399999999998000\t0.97419223604359206000\t0.73971801835783457000\t-0.01391221798709984900\t2.00323341589133360000\t"
                        + "0.42225299999999999000\t0.70461499999999999000\t1.00215405146211660000\t0.73418463980596194000\t-0.00042721787450638975\t2.06083725051510890000\t"
                        + "0.42225299999999999000\t1.00000000000000000000\t1.00541663205978730000\t0.73391966224136052000\t0.00007745983642219967\t2.06797441112966540000\t"
                        + "0.46228500000000000000\t0.09945300000000000000\t0.80825074300769073000\t0.77512009069181820000\t0.02506209175372302300\t1.70367399757211290000\t"
                        + "0.46228500000000000000\t0.14613000000000001000\t0.86041774723638809000\t0.78743241358744553000\t-0.00253276294775680930\t1.80828799112923420000\t"
                        + "0.46228500000000000000\t0.19914200000000001000\t0.87386368408682447000\t0.77431445482937034000\t0.00347382917884794810\t1.82193675973315730000\t"
                        + "0.46228500000000000000\t0.26048300000000002000\t0.90117250952322170000\t0.77250999014433508000\t-0.00609703195441201140\t1.87483763869877570000\t"
                        + "0.46228500000000000000\t0.33326800000000001000\t0.92305165865194772000\t0.76712960029101529000\t-0.00987312641410125790\t1.91530668898030830000\t"
                        + "0.46228500000000000000\t0.42276900000000001000\t0.94147732861131073000\t0.75624912096328689000\t-0.01760687597195548900\t1.94536825995615100000\t"
                        + "0.46228500000000000000\t0.53902499999999998000\t0.96172483833970979000\t0.74220850360571400000\t-0.01930726777886795200\t1.97816588846153210000\t"
                        + "0.46228500000000000000\t0.70519799999999999000\t0.99089962958546807000\t0.73680635904747793000\t-0.00242392199602476560\t2.03781463691854150000\t"
                        + "0.46228500000000000000\t1.00000000000000000000\t0.99426840912241654000\t0.73656433181708991000\t0.00211598279555167070\t2.04514020880829110000\t"
                        + "0.50000000000000000000\t0.10000000000000001000\t0.78707892681425728000\t0.77392278192279507000\t0.00491873645248108900\t1.66340436375967720000\t"
                        + "0.50000000000000000000\t0.14664800000000000000\t0.84281333062384212000\t0.78960831661036845000\t-0.02177964737717095300\t1.77651214006970040000\t"
                        + "0.50000000000000000000\t0.19962800000000000000\t0.85633284993660908000\t0.77524135033941388000\t-0.01199799046984418400\t1.78852802419470370000\t"
                        + "0.50000000000000000000\t0.26093300000000003000\t0.88553430296040581000\t0.77475577803863060000\t-0.01968896799359355300\t1.84547810045840690000\t"
                        + "0.50000000000000000000\t0.33367400000000003000\t0.90845739346234233000\t0.76975564057044699000\t-0.02043209485368169600\t1.88759097699153890000\t"
                        + "0.50000000000000000000\t0.42312000000000000000\t0.92832121638931142000\t0.75889956424217653000\t-0.02554668817560214200\t1.91998355419574680000\t"
                        + "0.50000000000000000000\t0.53930500000000003000\t0.94957229998886394000\t0.74419730241320337000\t-0.02466536801376462100\t1.95371785864912170000\t"
                        + "0.50000000000000000000\t0.70537700000000003000\t0.97997401816072671000\t0.73897954636549890000\t-0.00441312564409457840\t2.01543597053598010000\t"
                        + "0.50000000000000000000\t1.00000000000000000000\t0.98343537747378662000\t0.73875733818516021000\t0.00414586107150597890\t2.02291606674685910000\t"
                        + "0.53771500000000005000\t0.09945300000000000000\t0.76635025241330901000\t0.76994038219561278000\t-0.01617769413273692200\t1.62461667551763940000\t"
                        + "0.53771500000000005000\t0.14613000000000001000\t0.82527723984209389000\t0.79108347127239709000\t-0.04182182185976748800\t1.74617288430012850000\t"
                        + "0.53771500000000005000\t0.19914200000000001000\t0.83878566694711887000\t0.77620651686502629000\t-0.02773429126328742400\t1.75602816118146010000\t"
                        + "0.53771500000000005000\t0.26048300000000002000\t0.86945150972339968000\t0.77664491830640126000\t-0.03358014058237866800\t1.81556925925952140000\t"
                        + "0.53771500000000005000\t0.33326800000000001000\t0.89312650026751750000\t0.77175738765729440000\t-0.03156078444290676100\t1.85841432823961130000\t"
                        + "0.53771500000000005000\t0.42276900000000001000\t0.91433385244140153000\t0.76090663864152275000\t-0.03414041489886791800\t1.89280972725818250000\t"
                        + "0.53771500000000005000\t0.53902499999999998000\t0.93669171089624059000\t0.74565396614442403000\t-0.03053416494195206700\t1.92765507901878430000\t"
                        + "0.53771500000000005000\t0.70519799999999999000\t0.96848586221042432000\t0.74080468853379677000\t-0.00660360129014163090\t1.99182429675642750000\t"
                        + "0.53771500000000005000\t1.00000000000000000000\t0.97203544943197451000\t0.74060978656962506000\t0.00637648434136586000\t1.99944845146682540000\t"
                        + "0.57774700000000001000\t0.09767299999999999600\t0.74179533217798954000\t0.76499787705913325000\t-0.03788723663869168800\t1.57651721428961620000\t"
                        + "0.57774700000000001000\t0.14444199999999999000\t0.80331201249275241000\t0.78922872388176146000\t-0.06242147319483677000\t1.70468512462224830000\t"
                        + "0.57774700000000001000\t0.19755900000000001000\t0.81725658463768935000\t0.77407482889638657000\t-0.04502314853320501400\t1.71419953242085790000\t"
                        + "0.57774700000000001000\t0.25902199999999997000\t0.84994170873849484000\t0.77665044313085674000\t-0.04896153680781807600\t1.77837243831607080000\t"
                        + "0.57774700000000001000\t0.33195100000000000000\t0.87535903043636121000\t0.77275368024336244000\t-0.04386177477215755900\t1.82431776317083980000\t"
                        + "0.57774700000000001000\t0.42162800000000000000\t0.89868721353532621000\t0.76236041364940488000\t-0.04362976194660971000\t1.86234077505121070000\t"
                        + "0.57774700000000001000\t0.53811399999999998000\t0.92260539995880253000\t0.74671207364579684000\t-0.03700383290055651900\t1.89912947702542210000\t"
                        + "0.57774700000000001000\t0.70461499999999999000\t0.95599559826838931000\t0.74232083302505758000\t-0.00902609636307812570\t1.96609191961181900000\t"
                        + "0.57774700000000001000\t1.00000000000000000000\t0.95962283271108995000\t0.74215368285381245000\t0.00884149314697615410\t1.97382848600048180000\t"
                        + "0.62040300000000004000\t0.09441199999999999600\t0.69358027691195823000\t0.75128018076745728000\t-0.05832202602801412500\t1.48821174848046180000\t"
                        + "0.62040300000000004000\t0.14135000000000000000\t0.76872490517065073000\t0.78590076672871889000\t-0.08279766784841050000\t1.64351206805522290000\t"
                        + "0.62040300000000004000\t0.19465900000000000000\t0.78873487162426426000\t0.77228520187662131000\t-0.06172077955423192800\t1.66183160826405850000\t"
                        + "0.62040300000000004000\t0.25634400000000002000\t0.82660211819090923000\t0.77615786434722023000\t-0.06441015643699693500\t1.73459205836441080000\t"
                        + "0.62040300000000004000\t0.32953700000000002000\t0.85554777272589799000\t0.77286492992866329000\t-0.05720481397567823300\t1.78630106408582010000\t"
                        + "0.62040300000000004000\t0.41953800000000002000\t0.88176958835680597000\t0.76288499290295786000\t-0.05423720583814265600\t1.82917987846967070000\t"
                        + "0.62040300000000004000\t0.53644499999999995000\t0.90762487693586935000\t0.74697142647466086000\t-0.04425909128071287000\t1.86857423869059970000\t"
                        + "0.62040300000000004000\t0.70354799999999995000\t0.94275736982767566000\t0.74330823799153711000\t-0.01173371720918629600\t1.93867551685359720000\t"
                        + "0.62040300000000004000\t1.00000000000000000000\t0.94644346142843438000\t0.74317966519170475000\t0.01159174339541884000\t1.94648510040035090000\t"
                        + "0.66604699999999994000\t0.08935200000000000100\t0.66767019917843040000\t0.73848352046369414000\t-0.08904945470971660500\t1.43278309583094290000\t"
                        + "0.66604699999999994000\t0.13655200000000001000\t0.73849407610406415000\t0.77746639110979199000\t-0.11663182225282001000\t1.58592642868623780000\t"
                        + "0.66604699999999994000\t0.19015899999999999000\t0.75957456656974121000\t0.76550237260531728000\t-0.08755919853355774400\t1.60565268541392010000\t"
                        + "0.66604699999999994000\t0.25218900000000000000\t0.80488382100841449000\t0.77314899286228611000\t-0.08595866626472165000\t1.69337190076362100000\t"
                        + "0.66604699999999994000\t0.32579000000000002000\t0.83767551191070067000\t0.77135138494307576000\t-0.07380673174078235300\t1.75190361134771780000\t"
                        + "0.66604699999999994000\t0.41629500000000003000\t0.86629799551574438000\t0.76212446208250761000\t-0.06668409359976518200\t1.79862127508030810000\t"
                        + "0.66604699999999994000\t0.53385400000000005000\t0.89309197099778503000\t0.74625287026864562000\t-0.05248373881880817600\t1.83864527523151430000\t"
                        + "0.66604699999999994000\t0.70189100000000004000\t0.92915994446187145000\t0.74361247078787374000\t-0.01475025543524193800\t1.91032065049523460000\t"
                        + "0.66604699999999994000\t1.00000000000000000000\t0.93284654861518179000\t0.74352893952276811000\t0.01465505728076897100\t1.91808168811256260000\t"
                        + "0.71513300000000002000\t0.08207599999999999600\t0.77285472483941786000\t0.74338176639300180000\t-0.12721013795270447000\t1.62577868033486110000\t"
                        + "0.71513300000000002000\t0.12965299999999999000\t0.79956848566433247000\t0.77558362427779204000\t-0.14773228921109255000\t1.69654476171072920000\t"
                        + "0.71513300000000002000\t0.18368799999999999000\t0.79689966946671054000\t0.75937519888658178000\t-0.11949182711663890000\t1.66982614762403570000\t"
                        + "0.71513300000000002000\t0.24621299999999999000\t0.82388022530476845000\t0.76706895875217385000\t-0.11468459489645678000\t1.72562760143620200000\t"
                        + "0.71513300000000002000\t0.32040299999999999000\t0.84231318036149949000\t0.76664615054007257000\t-0.09453950432168567500\t1.75800823102122990000\t"
                        + "0.71513300000000002000\t0.41163100000000002000\t0.86214313914626739000\t0.75875435814576031000\t-0.08121743233806218200\t1.78853035751326920000\t"
                        + "0.71513300000000002000\t0.53012999999999999000\t0.88262637345384498000\t0.74366387856250948000\t-0.06150852123597104500\t1.81586987385555650000\t"
                        + "0.71513300000000002000\t0.69950900000000005000\t0.91616601678500309000\t0.74284174545191262000\t-0.01800614204194279600\t1.88273439028157590000\t"
                        + "0.71513300000000002000\t1.00000000000000000000\t0.91973036518744600000\t0.74282140022512810000\t0.01797217388166414900\t1.89021224315262850000\t"
                        + "0.76822100000000004000\t0.07202899999999999600\t0.93189887202931965000\t0.71186576315208150000\t-0.15183057140532644000\t1.92594579459352830000\t"
                        + "0.76822100000000004000\t0.12012700000000000000\t0.93174300488971307000\t0.75164832896675726000\t-0.15597919715152475000\t1.94341225352019740000\t"
                        + "0.76822100000000004000\t0.17475399999999999000\t0.91105656891022835000\t0.74140916153609826000\t-0.13491632613986654000\t1.88324864903868860000\t"
                        + "0.76822100000000004000\t0.23796300000000001000\t0.90369795583746171000\t0.75053496866765579000\t-0.12950164056155833000\t1.87238026935090710000\t"
                        + "0.76822100000000004000\t0.31296499999999999000\t0.89108953215447684000\t0.75456532009573696000\t-0.10798498312895695000\t1.84586792642889640000\t"
                        + "0.76822100000000004000\t0.40519100000000002000\t0.88419457506461108000\t0.75076635116671031000\t-0.09260477087091098500\t1.82661495645329500000\t"
                        + "0.76822100000000004000\t0.52498699999999998000\t0.88326531239216155000\t0.73844291802419504000\t-0.06932790952309088300\t1.81332012073198330000\t"
                        + "0.76822100000000004000\t0.69621999999999995000\t0.90604598558880245000\t0.74065155282980921000\t-0.02110086488378592700\t1.86023500651739200000\t"
                        + "0.76822100000000004000\t1.00000000000000000000\t0.90924881043888783000\t0.74070893546867456000\t0.02116784291396133600\t1.86697625195260960000\t"
                        + "0.82602200000000003000\t0.05845500000000000000\t1.01944315737051490000\t0.67817244688219480000\t-0.16358090433324252000\t2.09654731771127120000\t"
                        + "0.82602200000000003000\t0.10725700000000001000\t1.02083143399155850000\t0.72273712311368354000\t-0.14926395336494236000\t2.11579537759503240000\t"
                        + "0.82602200000000003000\t0.16268299999999999000\t1.00474984452226070000\t0.71817859699267461000\t-0.12734741310432474000\t2.06669050522930410000\t"
                        + "0.82602200000000003000\t0.22681699999999999000\t0.98615112890951229000\t0.72855068179627891000\t-0.11879569761326185000\t2.02990228210849640000\t"
                        + "0.82602200000000003000\t0.30291499999999999000\t0.95943559414211010000\t0.73730247551087136000\t-0.10104858536249289000\t1.97482910007104050000\t"
                        + "0.82602200000000003000\t0.39649000000000001000\t0.92879945483906012000\t0.73836762939657052000\t-0.08984679560205159600\t1.90854544531143460000\t"
                        + "0.82602200000000003000\t0.51803900000000003000\t0.89910222818031804000\t0.73034334233078280000\t-0.07059599077743562700\t1.83906536809686650000\t"
                        + "0.82602200000000003000\t0.69177699999999998000\t0.90207809114790960000\t0.73659525850009933000\t-0.02295305209550337800\t1.84894464596610810000\t"
                        + "0.82602200000000003000\t1.00000000000000000000\t0.90458682594706674000\t0.73672112558957648000\t0.02317975630956098400\t1.85430754850885890000\t"
                        + "0.88945600000000002000\t0.04029200000000000100\t1.04916365208010800000\t0.59771873974047096000\t-0.17056657164184374000\t2.12331682962643510000\t"
                        + "0.88945600000000002000\t0.09003500000000000400\t1.04570208881854200000\t0.68325394946983098000\t-0.14551612636958702000\t2.14793316048968740000\t"
                        + "0.88945600000000002000\t0.14652999999999999000\t1.03680704198137460000\t0.69754869362182603000\t-0.12300070762785373000\t2.12499734623158650000\t"
                        + "0.88945600000000002000\t0.21190100000000001000\t1.02041853192845710000\t0.71084884291501471000\t-0.10698325122228668000\t2.09229318309576890000\t"
                        + "0.88945600000000002000\t0.28946800000000000000\t1.00053294201605540000\t0.72254348559116799000\t-0.08745770796115318000\t2.05262983932519290000\t"
                        + "0.88945600000000002000\t0.38484800000000002000\t0.96867600844134316000\t0.72650497208959974000\t-0.07551467054879966400\t1.98393646006985520000\t"
                        + "0.88945600000000002000\t0.50874100000000000000\t0.92335730185658804000\t0.72138248660561366000\t-0.06314620202946051600\t1.88228011969870070000\t"
                        + "0.88945600000000002000\t0.68583099999999997000\t0.90682244940879631000\t0.73102072191462297000\t-0.02302540404790504700\t1.85436697019362030000\t"
                        + "0.88945600000000002000\t1.00000000000000000000\t0.90841833884175593000\t0.73121215492356895000\t0.02339769294360303700\t1.85791824650392460000\t"
                        + "0.95973900000000001000\t0.01599300000000000000\t1.10418186404474120000\t0.52771429619482046000\t-0.11933650086955920000\t2.21274320204869610000\t"
                        + "0.95973900000000001000\t0.06699600000000000000\t1.07030634477072640000\t0.63357579954255372000\t-0.09540529203036506000\t2.16939208251455180000\t"
                        + "0.95973900000000001000\t0.12492100000000000000\t1.05893193762065520000\t0.67441277545495693000\t-0.09841361617604745000\t2.15783281209081190000\t"
                        + "0.95973900000000001000\t0.19194800000000001000\t1.03363490089632170000\t0.69379687868108753000\t-0.08804453740738557600\t2.10802306234016030000\t"
                        + "0.95973900000000001000\t0.27147800000000000000\t1.01541916537988810000\t0.70939744673557259000\t-0.07301960805650900600\t2.07504792248204680000\t"
                        + "0.95973900000000001000\t0.36927300000000002000\t0.99013988177424905000\t0.71632402072008383000\t-0.05844898862759559400\t2.02249401273472260000\t"
                        + "0.95973900000000001000\t0.49630299999999999000\t0.94555857833444101000\t0.71312058669006262000\t-0.05002364892710584000\t1.92296266186148120000\t"
                        + "0.95973900000000001000\t0.67787699999999995000\t0.91901509112597557000\t0.72403671028389816000\t-0.02136955408994570300\t1.87439546534188730000\t"
                        + "0.95973900000000001000\t1.00000000000000000000\t0.91976959974001027000\t0.72424938945263473000\t0.02182118613105065600\t1.87621736647993890000\t"
                        + "1.03853299999999990000\t0.00000000000000000000\t1.10714334501950140000\t0.57093118133678378000\t-0.03355598127522086600\t2.24029526034277810000\t"
                        + "1.03853299999999990000\t0.05183200000000000300\t1.08291092638053590000\t0.63513345914651120000\t-0.02832609217694476800\t2.19813703866234980000\t"
                        + "1.03853299999999990000\t0.11069800000000000000\t1.07276262123663990000\t0.67877084964963841000\t-0.04787562516540869900\t2.18991709489482080000\t"
                        + "1.03853299999999990000\t0.17881400000000000000\t1.04330424810195170000\t0.69124108330271938000\t-0.05065895345454046000\t2.12566743894389010000\t"
                        + "1.03853299999999990000\t0.25963700000000001000\t1.02255188056214740000\t0.70286476034882484000\t-0.04878714913081343100\t2.08508848628417320000\t"
                        + "1.03853299999999990000\t0.35902200000000001000\t0.99994259358611703000\t0.70846558364351953000\t-0.03858617840639123900\t2.03794480999008520000\t"
                        + "1.03853299999999990000\t0.48811700000000002000\t0.96218411525391179000\t0.70636819197801604000\t-0.03491893145781277400\t1.95382054523671120000\t"
                        + "1.03853299999999990000\t0.67264100000000004000\t0.93451941661241666000\t0.71693090386023028000\t-0.01868525286275223000\t1.90184626986214480000\t"
                        + "1.03853299999999990000\t1.00000000000000000000\t0.93476815146151027000\t0.71720923427607663000\t0.01912235021715539400\t1.90264424686219290000\t"
                        + "1.12818500000000000000\t0.00000000000000000000\t1.03972083187174900000\t0.62924771127212764000\t-0.01131117499454207400\t2.10267323784420370000\t"
                        + "1.12818500000000000000\t0.05183200000000000300\t1.04648462883074410000\t0.66083760181622020000\t-0.01463403607037418300\t2.12530248443562140000\t"
                        + "1.12818500000000000000\t0.11069800000000000000\t1.04705454038424330000\t0.69206167658414186000\t-0.02271927380866790200\t2.13737497977290980000\t"
                        + "1.12818500000000000000\t0.17881400000000000000\t1.03130432841601550000\t0.69629845764510157000\t-0.02567348947658805100\t2.10074611501170240000\t"
                        + "1.12818500000000000000\t0.25963700000000001000\t1.01802796753187060000\t0.70076523195079432000\t-0.02757702141104180500\t2.07314001348308620000\t"
                        + "1.12818500000000000000\t0.35902200000000001000\t1.00224258077390130000\t0.70335583033633853000\t-0.02066158164610946600\t2.03955886666145060000\t"
                        + "1.12818500000000000000\t0.48811700000000002000\t0.97395924656326216000\t0.70192114190565269000\t-0.02084917007866912000\t1.97655012749492840000\t"
                        + "1.12818500000000000000\t0.67264100000000004000\t0.94900406410686955000\t0.71014679953275328000\t-0.01543381486003460500\t1.92805421056851010000\t"
                        + "1.12818500000000000000\t1.00000000000000000000\t0.94893990667221650000\t0.71038715067961022000\t0.01581845342142165400\t1.92813857471818780000\t"
                        + "1.23217500000000000000\t0.00000000000000000000\t1.01788853906487240000\t0.65174487494884814000\t-0.00451914560744932310\t2.05957092916111910000\t"
                        + "1.23217500000000000000\t0.05183200000000000300\t1.02743873196007000000\t0.67543346168718088000\t-0.00743824699645905670\t2.08836680477266250000\t"
                        + "1.23217500000000000000\t0.11069800000000000000\t1.02777292990166420000\t0.69885313205639588000\t-0.00835230686481021330\t2.09734803960369920000\t"
                        + "1.23217500000000000000\t0.17881400000000000000\t1.01874689433437470000\t0.70081022505324864000\t-0.01116934694410449100\t2.07546887393638850000\t"
                        + "1.23217500000000000000\t0.25963700000000001000\t1.01131981038004940000\t0.70047419676817724000\t-0.01263988415152978200\t2.05822017047336200000\t"
                        + "1.23217500000000000000\t0.35902200000000001000\t1.00288506380354470000\t0.70069205952213820000\t-0.00701032626980942990\t2.03974037091640390000\t"
                        + "1.23217500000000000000\t0.48811700000000002000\t0.98343718347636988000\t0.69974980196121339000\t-0.00932862038451891250\t1.99634524494585520000\t"
                        + "1.23217500000000000000\t0.67264100000000004000\t0.96159553359891425000\t0.70472334515052737000\t-0.01194666994553815100\t1.95167955035028220000\t"
                        + "1.23217500000000000000\t1.00000000000000000000\t0.96139122270490107000\t0.70499750780496739000\t0.01235583333341742700\t1.95142999572421270000\t"
                        + "1.35597700000000000000\t0.00000000000000000000\t1.00467797382075030000\t0.65843885538619473000\t-0.00355929570002330890\t2.03013860085960210000\t"
                        + "1.35597700000000000000\t0.05183200000000000300\t1.01697222331091260000\t0.68337405831796305000\t-0.00356132101049765230\t2.06820943815186540000\t"
                        + "1.35597700000000000000\t0.11069800000000000000\t1.01797694760130760000\t0.70312046737354583000\t0.00049958820248128697\t2.07763980767236990000\t"
                        + "1.35597700000000000000\t0.17881400000000000000\t1.01147541426913980000\t0.70453041387759507000\t-0.00210883698719981780\t2.06139811708546490000\t"
                        + "1.35597700000000000000\t0.25963700000000001000\t1.00665598980281560000\t0.70088546306633837000\t-0.00285831037837292260\t2.04804103830543970000\t"
                        + "1.35597700000000000000\t0.35902200000000001000\t1.00299548389505990000\t0.69901067601339528000\t0.00149098960231753380\t2.03916848054479600000\t"
                        + "1.35597700000000000000\t0.48811700000000002000\t0.99074937863080892000\t0.69838432177736609000\t-0.00189759826753813890\t2.01174444292146770000\t"
                        + "1.35597700000000000000\t0.67264100000000004000\t0.97251884259346100000\t0.70018195255558691000\t-0.00913724279219609370\t1.97220277641140230000\t"
                        + "1.35597700000000000000\t1.00000000000000000000\t0.97222776251920284000\t0.70042661269302731000\t0.00959587980714557940\t1.97165315972202330000\t"
                        + "1.50896199999999990000\t0.00000000000000000000\t0.99626877395035152000\t0.66867442112280728000\t-0.00415784062506694210\t2.01258873861233620000\t"
                        + "1.50896199999999990000\t0.05183200000000000300\t1.00843514713890330000\t0.69094745141185099000\t-0.00336772438588442020\t2.05092298618908990000\t"
                        + "1.50896199999999990000\t0.11069800000000000000\t1.01013527889631600000\t0.70509451995538408000\t0.00217447484555702110\t2.06017510221163170000\t"
                        + "1.50896199999999990000\t0.17881400000000000000\t1.00575451786517740000\t0.70553929677823635000\t0.00082167584862451702\t2.04882824004814970000\t"
                        + "1.50896199999999990000\t0.25963700000000001000\t1.00272231827882560000\t0.70103411274273053000\t0.00077917196329018758\t2.03909480380526190000\t"
                        + "1.50896199999999990000\t0.35902200000000001000\t1.00181640712512370000\t0.69864679510005312000\t0.00365659572816478140\t2.03602879883067620000\t"
                        + "1.50896199999999990000\t0.48811700000000002000\t0.99584576042298545000\t0.69828516543303132000\t0.00103697673100834520\t2.02245351756071660000\t"
                        + "1.50896199999999990000\t0.67264100000000004000\t0.98289298314731866000\t0.69700832701128246000\t-0.00632224517170764270\t1.99210048859912650000\t"
                        + "1.50896199999999990000\t1.00000000000000000000\t0.98270649407291588000\t0.69735703413000716000\t0.00672716998587883850\t1.99182913402493140000\t"
                        + "1.70927000000000010000\t0.00000000000000000000\t0.99443066293963001000\t0.68414510919162486000\t-0.00245894062888764010\t2.01087633701439250000\t"
                        + "1.70927000000000010000\t0.05183200000000000300\t0.99931571878044767000\t0.69299540149766470000\t-0.00227313294438145910\t2.02696036014201120000\t"
                        + "1.70927000000000010000\t0.11069800000000000000\t1.00000024433295280000\t0.69813212181050055000\t0.00035783968567941395\t2.03111140699994050000\t"
                        + "1.70927000000000010000\t0.17881400000000000000\t0.99826579677890248000\t0.69834203804117911000\t-0.00006936619302191276\t2.02707323279872930000\t"
                        + "1.70927000000000010000\t0.25963700000000001000\t0.99728130716948904000\t0.69673818172514979000\t-0.00008360900503007445\t2.02390986833914480000\t"
                        + "1.70927000000000010000\t0.35902200000000001000\t0.99816445223017081000\t0.69671956286570880000\t0.00147827146483655810\t2.02594300449474930000\t"
                        + "1.70927000000000010000\t0.48811700000000002000\t0.99758760797665491000\t0.69743975333292374000\t0.00127340990507565250\t2.02481440209573730000\t"
                        + "1.70927000000000010000\t0.67264100000000004000\t0.99183042528688570000\t0.69520649517964950000\t-0.00271296570539258670\t2.00983528438261330000\t"
                        + "1.70927000000000010000\t1.00000000000000000000\t0.99173402203982175000\t0.69536616954623354000\t0.00286358376714936860\t2.00969068730405680000\t"
                        + "2.00000000000000000000\t0.00000000000000000000\t0.98893204982299698000\t0.68601847747313072000\t-0.00077441297957429357\t1.99944460301373540000\t"
                        + "2.00000000000000000000\t0.05183200000000000300\t0.99496482392452390000\t0.69490417924340242000\t-0.00089932956421385026\t2.01826898378883610000\t"
                        + "2.00000000000000000000\t0.11069800000000000000\t0.99758002774680332000\t0.69817363724570369000\t-0.00017900566354726887\t2.02561281336582870000\t"
                        + "2.00000000000000000000\t0.17881400000000000000\t0.99742247529225248000\t0.69762004671702438000\t-0.00069678371815480285\t2.02466631825049200000\t"
                        + "2.00000000000000000000\t0.25963700000000001000\t0.99665514787327270000\t0.69657817756032725000\t-0.00012683044870211407\t2.02239449307789520000\t"
                        + "2.00000000000000000000\t0.35902200000000001000\t0.99681958215911959000\t0.69690700779794335000\t0.00143143157903056780\t2.02303146312248310000\t"
                        + "2.00000000000000000000\t0.48811700000000002000\t0.99738566254287120000\t0.69738173234070178000\t0.00108652508990310960\t2.02429147660805510000\t"
                        + "2.00000000000000000000\t0.67264100000000004000\t0.99585989423632015000\t0.69412881512579783000\t-0.00287549702250277940\t2.01811130911489260000\t"
                        + "2.00000000000000000000\t1.00000000000000000000\t0.99585989423632015000\t0.69412881512579783000\t-0.00287549702250277940\t2.01811130911489260000";

    var i:int, j:int, k:int, n:int; /* Dummy counters */
    var scrap:Number, scrap2:Number; /* Temporary storage */

    /* Set scale factor for interpolation */
    scale = datasizes[size];

    /* Open data file */
    var tokensArray:Vector.<String>;
    tokensArray = Vector.<String>(data.split("\t"));
   
    imaxin=tokensArray[0]*1;
    jmaxin=tokensArray[1]*1;
    oldval = initTripleArray(nf,imaxin+1,jmaxin+1);
    
    
    var n_temp:int=0;
    var itemp:int=0
    var jmaxin_temp:int = 0;
    
    /* PEYER - No need to init to 0.0
    for(n_temp=0;n_temp<nf;n_temp++)
    {
      
      for(itemp=0;itemp<=imaxin;itemp++)
      {
        for(jmaxin_temp=0;jmaxin_temp<jmaxin;jmaxin_temp++)
        {
        //print("test: "+n_temp+":"+itemp);
          oldval[n_temp][itemp][jmaxin_temp]=0.0;
        }
      }
      
    }
    for(n_temp=0;n_temp<nf;n_temp++)
    {
      for(itemp=0;itemp<=imaxin;itemp++)
      {
        for(jtemp=0;jtemp<=jmaxin;jtemp++)
        {
          oldval[n_temp][itemp][jtemp]=0.0;
        }
      }
    }
    
    */
    var counter:int=2;
    for (i = 0; i < imaxin; i++) {
      for (j = 0; j < jmaxin; j++) {
        for (k = 0; k < nf; k++) {
          oldval[k][i][j] = tokensArray[counter]*1.0;
          counter++;
        }
      }
    }
    
    
    // interpolate onto finer grid
    imax = (imaxin - 1) * scale + 1;
    jmax = (jmaxin - 1) * scale + 1;
    //print("imax is: "+imax);
    //print("jmax is: "+jmax);
    //print("nf is: "+nf);
    /*
    for(var loop0=0;loop0<nf;loop0++)
    {
      for(var loop1=0;loop1<imaxin;loop1++)
      {
        for(var loop2=0;loop2<jmaxin;loop2++)
        {
          print("oldval["+loop0+"]["+loop1+"]["+loop2+"]: "+oldval[loop0][loop1][loop2]);
        }
      }
    }
    * */
    newval = initTripleArray(nf,imax,jmax);//new double[nf][imax][jmax];

    for (k = 0; k < nf; k++) {
      for (i = 0; i < imax; i++) {
        for (j = 0; j < jmax; j++) {
          //Alex: since Javascript doesn't do casting we need to "cast" it to int
          var iold = Math.floor(i / scale);
          var jold = Math.floor(j / scale);
          var xf = ( i % scale) / (scale);
          var yf = ( j % scale) / (scale);
          newval[k][i][j] = (1.0 - xf) * (1.0 - yf)
              * oldval[k][iold][jold] + (1.0 - xf) * yf
              * oldval[k][iold][jold + 1] + xf * (1.0 - yf)
              * oldval[k][iold + 1][jold] + xf * yf
              * oldval[k][iold + 1][jold + 1];
        }
      }
    }
    // create arrays

    deltat = initDoubleArray(imax+1,jmax+2);//new double[imax + 1][jmax + 2];
    opg = initDoubleArray(imax+2,jmax+2);//new double[imax + 2][jmax + 2];
    pg = initDoubleArray(imax+2,jmax+2);//new double[imax + 2][jmax + 2];
    pg1 = initDoubleArray(imax+2,jmax+2);//new double[imax + 2][jmax + 2];
    sxi = initDoubleArray(imax+2, jmax+2);//new double[imax + 2][jmax + 2];
    
    seta = initDoubleArray(imax+2, jmax+2);//new double[imax + 2][jmax + 2];
    
    tg = initDoubleArray(imax+2, jmax+2);//new double[imax + 2][jmax + 2];
    tg1 = initDoubleArray(imax+2, jmax+2);//new double[imax + 2][jmax + 2];
    ug = initDoubleStatevectorArray(imax+2, jmax+2);//new Statevector[imax + 2][jmax + 2];
    a = initDoubleArray(imax, jmax);//new double[imax][jmax];
    d = initDoubleStatevectorArray(imax+2, jmax+2);//new Statevector[imax + 2][jmax + 2];
    f = initDoubleStatevectorArray(imax+2, jmax+2);//new Statevector[imax + 2][jmax + 2];
    g = initDoubleStatevectorArray(imax+2, jmax+2);//new Statevector[imax + 2][jmax + 2];
    r = initDoubleStatevectorArray(imax+2, jmax+2);//new Statevector[imax + 2][jmax + 2];
    ug1 = initDoubleStatevectorArray(imax+2, jmax+2);//new Statevector[imax + 2][jmax + 2];
    xnode = initDoubleArray(imax, jmax);//new double[imax][jmax];
    ynode = initDoubleArray(imax, jmax);//new double[imax][jmax];


/*  PEYER - What is the zeroing out for?
    for(var tempi:int=0;tempi<imax+2;tempi++)
    {
      for(var tempj:int=0;tempj<jmax+2;tempj++)
      {
        tg[tempi][tempj]=0.0;
        tg1[tempi][tempj]=0.0;
        pg[tempi][tempj]=0.0;
        ug[tempi][tempj]=0.0;
      }
    }
*/
    
    for (i = 0; i < imax + 2; ++i)
      for (j = 0; j < jmax + 2; ++j) {
        d[i][j] = new Statevector();
        f[i][j] = new Statevector();
        g[i][j] = new Statevector();
        r[i][j] = new Statevector();
        ug[i][j] = new Statevector();
        ug1[i][j] = new Statevector();
      }

    /* Set farfield values (we use normalized units for everything */
    cff = 1.0;
    vff = 0.0;
    pff = 1.0 / gamma;
    rhoff = 1.0;
    tff = pff / (rhoff * rgas);

    // Copy the interpolated data to arrays

    for (i = 0; i < imax; i++) {
      for (j = 0; j < jmax; j++) {

        xnode[i][j] = newval[0][i][j];
        ynode[i][j] = newval[1][i][j];
        ug[i + 1][j + 1].a = newval[2][i][j];
        ug[i + 1][j + 1].b = newval[3][i][j];
        ug[i + 1][j + 1].c = newval[4][i][j];
        ug[i + 1][j + 1].d = newval[5][i][j];

        scrap = ug[i + 1][j + 1].c / ug[i + 1][j + 1].a;
        scrap2 = ug[i + 1][j + 1].b / ug[i + 1][j + 1].a;
        tg[i + 1][j + 1] = ug[i + 1][j + 1].d / ug[i + 1][j + 1].a
            - (0.5 * (scrap * scrap + scrap2 * scrap2));
        tg[i + 1][j + 1] = tg[i + 1][j + 1] / Cv;
        pg[i + 1][j + 1] = rgas * ug[i + 1][j + 1].a * tg[i + 1][j + 1];
      }
    }
    
    /* Calculate grid cell areas */
    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j)
      {
        a[i][j] = 0.5 * ((xnode[i][j] - xnode[i - 1][j - 1])
            * (ynode[i - 1][j] - ynode[i][j - 1]) - (ynode[i][j] - ynode[i - 1][j - 1])
            * (xnode[i - 1][j] - xnode[i][j - 1]));
        //print("a["+i+"]["+j+"] = "+a[i][j]);
      }
    // throw away temporary arrays
    oldval = newval = null;
  }
  function printTG(localtg:Vector.<Vector.<Number>>):void
  {
    print("entering printTG");
    for(var loop1:int=0;loop1<max+2;loop1++)
        {
          for(var loop2:int=0;loop2<jmax+2;loop2++)
          {
            print("localtg["+loop1+"]["+loop2+"]: "+localtg[loop1][loop2]);
            if(localtg[loop1][loop2]<0&&false)
            {
              print("localtg["+loop1+"]["+loop2+"] is negative loop1:loop2 ="+loop1+":"+loop2+":"+localtg[loop1][loop2]);
              //errorCheck=true;
              //return;
            }
            if(isNaN(localtg[loop1][loop2]) || localtg[loop1][loop2]=="NaN")
            {
              print("localtg is NaN loop1:loop2 ="+loop1+":"+loop2+":"+localtg[loop1][loop2]);
              errorCheck=true;
              return;
            }
            
          }
        }
  }
  
  function printUG(localug:Vector.<Vector.<Statevector>>):void
  {
    
    for(var loop1:int=0;loop1<localug.length;loop1++)
        {
          for(var loop2:int=0;loop2<localug[loop1].length;loop2++)
          {
            print("localug["+loop1+"]["+loop2+"]: "+localug[loop1][loop2].a+":"+localug[loop1][loop2].b+":"+localug[loop1][loop2].c+":"+localug[loop1][loop2].d);
          }
        }
  }
  
  function doIteration():void {
    var scrap:Number;
    var i:int, j:int;
    
    /* Record the old pressure values */
    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j) {
        opg[i][j] = pg[i][j];
      }
    
    calculateDummyCells(pg, tg, ug);
    //printTG();
    calculateDeltaT();
    //printTG();
    calculateDamping(pg, ug);
    //printTG();
    /* Do the integration */
    /* Step 1 */
    //print("Step1");
    calculateF(pg, tg, ug);
    //printTG();
    calculateG(pg, tg, ug);
    //printTG();
    calculateR();
    //printTG();

    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j) {
        ug1[i][j].a = ug[i][j].a - 0.25 * deltat[i][j] / a[i][j]
            * (r[i][j].a - d[i][j].a);
        ug1[i][j].b = ug[i][j].b - 0.25 * deltat[i][j] / a[i][j]
            * (r[i][j].b - d[i][j].b);
        ug1[i][j].c = ug[i][j].c - 0.25 * deltat[i][j] / a[i][j]
            * (r[i][j].c - d[i][j].c);
        ug1[i][j].d = ug[i][j].d - 0.25 * deltat[i][j] / a[i][j]
            * (r[i][j].d - d[i][j].d);
      }
    calculateStateVar(pg1, tg1, ug1);

    /* Step 2 */
    //print("step 2");
    //printTG();
    calculateDummyCells(pg1, tg1, ug1);
    calculateF(pg1, tg1, ug1);
    calculateG(pg1, tg1, ug1);
    calculateR();
    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j) {
        ug1[i][j].a = ug[i][j].a - 0.33333 * deltat[i][j] / a[i][j]
            * (r[i][j].a - d[i][j].a);
        ug1[i][j].b = ug[i][j].b - 0.33333 * deltat[i][j] / a[i][j]
            * (r[i][j].b - d[i][j].b);
        ug1[i][j].c = ug[i][j].c - 0.33333 * deltat[i][j] / a[i][j]
            * (r[i][j].c - d[i][j].c);
        ug1[i][j].d = ug[i][j].d - 0.33333 * deltat[i][j] / a[i][j]
            * (r[i][j].d - d[i][j].d);
      }
    calculateStateVar(pg1, tg1, ug1);

    /* Step 3 */
    //print("step 3");
    //printTG();
    calculateDummyCells(pg1, tg1, ug1);
    calculateF(pg1, tg1, ug1);
    calculateG(pg1, tg1, ug1);
    calculateR();
    for (i = 1; i < imax; ++i)
    {
      for (j = 1; j < jmax; ++j) {
        ug1[i][j].a = ug[i][j].a - 0.5 * deltat[i][j] / a[i][j]
            * (r[i][j].a - d[i][j].a);
        ug1[i][j].b = ug[i][j].b - 0.5 * deltat[i][j] / a[i][j]
            * (r[i][j].b - d[i][j].b);
        ug1[i][j].c = ug[i][j].c - 0.5 * deltat[i][j] / a[i][j]
            * (r[i][j].c - d[i][j].c);
        ug1[i][j].d = ug[i][j].d - 0.5 * deltat[i][j] / a[i][j]
            * (r[i][j].d - d[i][j].d);
      }
    }
    calculateStateVar(pg1, tg1, ug1);

    /* Step 4 (final step) */
    //print("step 4");
    //printTG();
    calculateDummyCells(pg1, tg1, ug1);
    //printTG();
    calculateF(pg1, tg1, ug1);
    //printTG();
    calculateG(pg1, tg1, ug1);
    //printTG();
    calculateR();
    //printTG();
    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j) {
        ug[i][j].a -= deltat[i][j] / a[i][j] * (r[i][j].a - d[i][j].a);
        ug[i][j].b -= deltat[i][j] / a[i][j] * (r[i][j].b - d[i][j].b);
        ug[i][j].c -= deltat[i][j] / a[i][j] * (r[i][j].c - d[i][j].c);
        ug[i][j].d -= deltat[i][j] / a[i][j] * (r[i][j].d - d[i][j].d);
      }
    calculateStateVar(pg, tg, ug);
    //printTG();

    /* calculate RMS Pressure Error */
    error = 0.0;
    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j) {
        scrap = pg[i][j] - opg[i][j];
        error += scrap * scrap;
      }
    error = Math.sqrt(error / ((imax - 1) * (jmax - 1)));
  }

  function calculateStateVar(localpg:Vector.<Vector.<Number>>, localtg:Vector.<Vector.<Number>>, localug:Vector.<Vector.<Statevector>>):void
  /* Calculates the new state values for range-kutta */
  /* Works for default values, 4/11 at 9:45 pm */
  {
    var temp:Number, temp2:Number;
    var i:int, j:int;

    for (i = 1; i < imax; ++i) {
      for (j = 1; j < jmax; ++j) {
        var check:Boolean=true;
        temp = localug[i][j].b;
        if(isNaN(temp) || temp == "NaN")
        {
          print("calculateStateVar temp is NaN: "+temp);
          errorCheck=true;
          return;
        }
        temp2 = localug[i][j].c;
        localtg[i][j] = localug[i][j].d / localug[i][j].a - 0.5
            * (temp * temp + temp2 * temp2)
            / (localug[i][j].a * localug[i][j].a);
        localtg[i][j] = localtg[i][j] / Cv;
        localpg[i][j] = localug[i][j].a * rgas * localtg[i][j];
      }
    }
  }

  function calculateR():void {
    //print("Entering calculateR");
    /* Works for default values, straight channel (all 0's) 4/11, 9:15 pm */

    var deltax:Number, deltay:Number;
    var temp:Number;
    var i:int, j:int;
    var scrap:Number;

    for (i = 1; i < imax; ++i) {
      for (j = 1; j < jmax; ++j) {

        /* Start by clearing R */
        r[i][j].a = 0.0;
        r[i][j].b = 0.0;
        r[i][j].c = 0.0;
        r[i][j].d = 0.0;

        /* East Face */
        deltay = (ynode[i][j] - ynode[i][j - 1]);
        deltax = (xnode[i][j] - xnode[i][j - 1]);
        temp = 0.5 * deltay;
        r[i][j].a += temp * (f[i][j].a + f[i + 1][j].a);
        r[i][j].b += temp * (f[i][j].b + f[i + 1][j].b);
        r[i][j].c += temp * (f[i][j].c + f[i + 1][j].c);
        r[i][j].d += temp * (f[i][j].d + f[i + 1][j].d);

        temp = -0.5 * deltax;
        r[i][j].a += temp * (g[i][j].a + g[i + 1][j].a);
        r[i][j].b += temp * (g[i][j].b + g[i + 1][j].b);
        r[i][j].c += temp * (g[i][j].c + g[i + 1][j].c);
        r[i][j].d += temp * (g[i][j].d + g[i + 1][j].d);

        /* South Face */
        deltay = (ynode[i][j - 1] - ynode[i - 1][j - 1]);
        deltax = (xnode[i][j - 1] - xnode[i - 1][j - 1]);
        if(isNaN(deltay) || deltay == "NaN")
        {
          print("calculateR deltay2 is NaN");
          errorCheck=true;
          return;
        }
        if(isNaN(deltax) || deltax == "NaN")
        {
          print("calculateR deltax2 is NaN");
          errorCheck=true;
          return;
        }
        temp = 0.5 * deltay;
        r[i][j].a += temp * (f[i][j].a + f[i][j - 1].a);
        r[i][j].b += temp * (f[i][j].b + f[i][j - 1].b);
        r[i][j].c += temp * (f[i][j].c + f[i][j - 1].c);
        r[i][j].d += temp * (f[i][j].d + f[i][j - 1].d);

        temp = -0.5 * deltax;
        r[i][j].a += temp * (g[i][j].a + g[i][j - 1].a);
        r[i][j].b += temp * (g[i][j].b + g[i][j - 1].b);
        r[i][j].c += temp * (g[i][j].c + g[i][j - 1].c);
        r[i][j].d += temp * (g[i][j].d + g[i][j - 1].d);
        
        /* West Face */
        deltay = (ynode[i - 1][j - 1] - ynode[i - 1][j]);
        deltax = (xnode[i - 1][j - 1] - xnode[i - 1][j]);

        temp = 0.5 * deltay;
        r[i][j].a += temp * (f[i][j].a + f[i - 1][j].a);
        r[i][j].b += temp * (f[i][j].b + f[i - 1][j].b);
        r[i][j].c += temp * (f[i][j].c + f[i - 1][j].c);
        r[i][j].d += temp * (f[i][j].d + f[i - 1][j].d);

        temp = -0.5 * deltax;
        r[i][j].a += temp * (g[i][j].a + g[i - 1][j].a);
        r[i][j].b += temp * (g[i][j].b + g[i - 1][j].b);
        r[i][j].c += temp * (g[i][j].c + g[i - 1][j].c);
        r[i][j].d += temp * (g[i][j].d + g[i - 1][j].d);

        /* North Face */
        deltay = (ynode[i - 1][j] - ynode[i][j]);
        deltax = (xnode[i - 1][j] - xnode[i][j]);

        temp = 0.5 * deltay;
        r[i][j].a += temp * (f[i][j].a + f[i + 1][j].a);
        r[i][j].b += temp * (f[i][j].b + f[i + 1][j].b);
        r[i][j].c += temp * (f[i][j].c + f[i + 1][j].c);
        r[i][j].d += temp * (f[i][j].d + f[i + 1][j].d);

        temp = -0.5 * deltax;
        r[i][j].a += temp * (g[i][j].a + g[i][j + 1].a);
        r[i][j].b += temp * (g[i][j].b + g[i][j + 1].b);
        r[i][j].c += temp * (g[i][j].c + g[i][j + 1].c);
        r[i][j].d += temp * (g[i][j].d + g[i][j + 1].d);
      }
    }
  }

  function calculateG( localpg:Vector.<Vector.<Number>>,  localtg:Vector.<Vector.<Number>>, localug:Vector.<Vector.<Statevector>>):void {
  //  print("Entering calculateG");
    /* Works for default values 4/10: 5:15 pm */
    var temp:Number, temp2:Number, temp3:Number;
    var v:Number;
    var i:int, j:int;

    for (i = 0; i < imax + 1; ++i) {
      for (j = 0; j < jmax + 1; ++j) {
        v = localug[i][j].c / localug[i][j].a;
        g[i][j].a = localug[i][j].c;
        g[i][j].b = localug[i][j].b * v;
        g[i][j].c = localug[i][j].c * v + localpg[i][j];
        temp = localug[i][j].b * localug[i][j].b;
        temp2 = localug[i][j].c * localug[i][j].c;
        temp3 = localug[i][j].a * localug[i][j].a;
        g[i][j].d = localug[i][j].c
            * (Cp * localtg[i][j] + (0.5 * (temp + temp2) / (temp3)));
      }
    }
  }

  function calculateF( localpg:Vector.<Vector.<Number>>,  localtg:Vector.<Vector.<Number>>,localug:Vector.<Vector.<Statevector>>):void {
    /* Works for default values 4/10: 4:50 pm */
    {
    //  print("Entering CalculateF");
      var u:Number;
      var temp1:Number, temp2:Number, temp3:Number;
      var i:int, j:int;

      for (i = 0; i < imax + 1; ++i) {
        for (j = 0; j < jmax + 1; ++j) {
          u = localug[i][j].b / localug[i][j].a;
          f[i][j].a = localug[i][j].b;
          f[i][j].b = localug[i][j].b * u + localpg[i][j];
          f[i][j].c = localug[i][j].c * u;
          temp1 = localug[i][j].b * localug[i][j].b;
          temp2 = localug[i][j].c * localug[i][j].c;
          temp3 = localug[i][j].a * localug[i][j].a;
          f[i][j].d = localug[i][j].b
              * (Cp * localtg[i][j] + (0.5 * (temp1 + temp2) / (temp3)));
        }
      }
    }
  }

  function calculateDamping( localpg:Vector.<Vector.<Number>>,  localug:Vector.<Vector.<Statevector>>):void {
  //  print("CalculateDamping");
    var adt:Number, sbar:Number;
    var nu2:Number;
    var nu4:Number;
    var tempdouble:Number;
    var ascrap:int, i:int, j:int;
    var temp = new Statevector();
    var temp2 = new Statevector();
    var scrap2 = new Statevector(), scrap4 = new Statevector();

    nu2 = secondOrderDamping * secondOrderNormalizer;
    nu4 = fourthOrderDamping * fourthOrderNormalizer;

    /* First do the pressure switches */
    /* Checked and works with defaults, 4/12 at 1:20 am */
    /* The east and west faces have been checked numerically vs.John's old */
    /* Scheme, and work! 4/13 @ 2:20 pm */
    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j) {
        sxi[i][j] = Math.abs(localpg[i + 1][j] - 2.0 * localpg[i][j]
            + localpg[i - 1][j])
            / localpg[i][j];
        seta[i][j] = Math.abs(localpg[i][j + 1] - 2.0 * localpg[i][j]
            + localpg[i][j - 1])
            / localpg[i][j];
      }

    /* Then calculate the fluxes */
    for (i = 1; i < imax; ++i) {
      for (j = 1; j < jmax; ++j) {

        /* Clear values */
        /* East Face */
        if (i > 1 && i < imax - 1) {
          adt = (a[i][j] + a[i + 1][j])
              / (deltat[i][j] + deltat[i + 1][j]);
          sbar = (sxi[i + 1][j] + sxi[i][j]) * 0.5;
        } else {
          adt = a[i][j] / deltat[i][j];
          sbar = sxi[i][j];
        }
        tempdouble = nu2 * sbar * adt;
        scrap2.a = tempdouble * (localug[i + 1][j].a - localug[i][j].a);
        scrap2.b = tempdouble * (localug[i + 1][j].b - localug[i][j].b);
        scrap2.c = tempdouble * (localug[i + 1][j].c - localug[i][j].c);
        scrap2.d = tempdouble * (localug[i + 1][j].d - localug[i][j].d);

        if (i > 1 && i < imax - 1) {
          temp = localug[i + 2][j].svect(localug[i - 1][j]);

          temp2.a = 3.0 * (localug[i][j].a - localug[i + 1][j].a);
          temp2.b = 3.0 * (localug[i][j].b - localug[i + 1][j].b);
          temp2.c = 3.0 * (localug[i][j].c - localug[i + 1][j].c);
          temp2.d = 3.0 * (localug[i][j].d - localug[i + 1][j].d);

          tempdouble = -nu4 * adt;
          scrap4.a = tempdouble * (temp.a + temp2.a);
          scrap4.b = tempdouble * (temp.a + temp2.b);
          scrap4.c = tempdouble * (temp.a + temp2.c);
          scrap4.d = tempdouble * (temp.a + temp2.d);
        } else {
          scrap4.a = 0.0;
          scrap4.b = 0.0;
          scrap4.c = 0.0;
          scrap4.d = 0.0;
        }

        temp.a = scrap2.a + scrap4.a;
        temp.b = scrap2.b + scrap4.b;
        temp.c = scrap2.c + scrap4.c;
        temp.d = scrap2.d + scrap4.d;
        d[i][j] = temp;

        /* West Face */
        if (i > 1 && i < imax - 1) {
          adt = (a[i][j] + a[i - 1][j])
              / (deltat[i][j] + deltat[i - 1][j]);
          sbar = (sxi[i][j] + sxi[i - 1][j]) * 0.5;
        } else {
          adt = a[i][j] / deltat[i][j];
          sbar = sxi[i][j];
        }

        tempdouble = -nu2 * sbar * adt;
        scrap2.a = tempdouble * (localug[i][j].a - localug[i - 1][j].a);
        scrap2.b = tempdouble * (localug[i][j].b - localug[i - 1][j].b);
        scrap2.c = tempdouble * (localug[i][j].c - localug[i - 1][j].c);
        scrap2.d = tempdouble * (localug[i][j].d - localug[i - 1][j].d);

        if (i > 1 && i < imax - 1) {
          temp = localug[i + 1][j].svect(localug[i - 2][j]);
          temp2.a = 3.0 * (localug[i - 1][j].a - localug[i][j].a);
          temp2.b = 3.0 * (localug[i - 1][j].b - localug[i][j].b);
          temp2.c = 3.0 * (localug[i - 1][j].c - localug[i][j].c);
          temp2.d = 3.0 * (localug[i - 1][j].d - localug[i][j].d);

          tempdouble = nu4 * adt;
          scrap4.a = tempdouble * (temp.a + temp2.a);
          scrap4.b = tempdouble * (temp.a + temp2.b);
          scrap4.c = tempdouble * (temp.a + temp2.c);
          scrap4.d = tempdouble * (temp.a + temp2.d);
        } else {
          scrap4.a = 0.0;
          scrap4.b = 0.0;
          scrap4.c = 0.0;
          scrap4.d = 0.0;
        }

        d[i][j].a += scrap2.a + scrap4.a;
        d[i][j].b += scrap2.b + scrap4.b;
        d[i][j].c += scrap2.c + scrap4.c;
        d[i][j].d += scrap2.d + scrap4.d;

        /* North Face */
        if (j > 1 && j < jmax - 1) {
          adt = (a[i][j] + a[i][j + 1])
              / (deltat[i][j] + deltat[i][j + 1]);
          sbar = (seta[i][j] + seta[i][j + 1]) * 0.5;
        } else {
          adt = a[i][j] / deltat[i][j];
          sbar = seta[i][j];
        }
        tempdouble = nu2 * sbar * adt;
        scrap2.a = tempdouble * (localug[i][j + 1].a - localug[i][j].a);
        scrap2.b = tempdouble * (localug[i][j + 1].b - localug[i][j].b);
        scrap2.c = tempdouble * (localug[i][j + 1].c - localug[i][j].c);
        scrap2.d = tempdouble * (localug[i][j + 1].d - localug[i][j].d);

        if (j > 1 && j < jmax - 1) {
          temp = localug[i][j + 2].svect(localug[i][j - 1]);
          temp2.a = 3.0 * (localug[i][j].a - localug[i][j + 1].a);
          temp2.b = 3.0 * (localug[i][j].b - localug[i][j + 1].b);
          temp2.c = 3.0 * (localug[i][j].c - localug[i][j + 1].c);
          temp2.d = 3.0 * (localug[i][j].d - localug[i][j + 1].d);

          tempdouble = -nu4 * adt;
          scrap4.a = tempdouble * (temp.a + temp2.a);
          scrap4.b = tempdouble * (temp.a + temp2.b);
          scrap4.c = tempdouble * (temp.a + temp2.c);
          scrap4.d = tempdouble * (temp.a + temp2.d);
        } else {
          scrap4.a = 0.0;
          scrap4.b = 0.0;
          scrap4.c = 0.0;
          scrap4.d = 0.0;
        }
        d[i][j].a += scrap2.a + scrap4.a;
        d[i][j].b += scrap2.b + scrap4.b;
        d[i][j].c += scrap2.c + scrap4.c;
        d[i][j].d += scrap2.d + scrap4.d;

        /* South Face */
        if (j > 1 && j < jmax - 1) {
          adt = (a[i][j] + a[i][j - 1])
              / (deltat[i][j] + deltat[i][j - 1]);
          sbar = (seta[i][j] + seta[i][j - 1]) * 0.5;
        } else {
          adt = a[i][j] / deltat[i][j];
          sbar = seta[i][j];
        }
        tempdouble = -nu2 * sbar * adt;
        scrap2.a = tempdouble * (localug[i][j].a - localug[i][j - 1].a);
        scrap2.b = tempdouble * (localug[i][j].b - localug[i][j - 1].b);
        scrap2.c = tempdouble * (localug[i][j].c - localug[i][j - 1].c);
        scrap2.d = tempdouble * (localug[i][j].d - localug[i][j - 1].d);

        if (j > 1 && j < jmax - 1) {
          temp = localug[i][j + 1].svect(localug[i][j - 2]);
          temp2.a = 3.0 * (localug[i][j - 1].a - localug[i][j].a);
          temp2.b = 3.0 * (localug[i][j - 1].b - localug[i][j].b);
          temp2.c = 3.0 * (localug[i][j - 1].c - localug[i][j].c);
          temp2.d = 3.0 * (localug[i][j - 1].d - localug[i][j].d);

          tempdouble = nu4 * adt;
          scrap4.a = tempdouble * (temp.a + temp2.a);
          scrap4.b = tempdouble * (temp.a + temp2.b);
          scrap4.c = tempdouble * (temp.a + temp2.c);
          scrap4.d = tempdouble * (temp.a + temp2.d);
        } else {
          scrap4.a = 0.0;
          scrap4.b = 0.0;
          scrap4.c = 0.0;
          scrap4.d = 0.0;
        }
        d[i][j].a += scrap2.a + scrap4.a;
        d[i][j].b += scrap2.b + scrap4.b;
        d[i][j].c += scrap2.c + scrap4.c;
        d[i][j].d += scrap2.d + scrap4.d;
      }
    }
  }

  function calculateDeltaT():void {
  //  print("CalculateDeltaT");
    var xeta:Number, yeta:Number, xxi:Number, yxi:Number; /* Local change in x and y */
    var i:int, j:int;
    var mint:Number;
    var c:Number, q:Number, r:Number;
    var safety_factor:Number = 0.7;

    for (i = 1; i < imax; ++i)
      for (j = 1; j < jmax; ++j) {
        xxi = (xnode[i][j] - xnode[i - 1][j] + xnode[i][j - 1] - xnode[i - 1][j - 1]) * 0.5;
        yxi = (ynode[i][j] - ynode[i - 1][j] + ynode[i][j - 1] - ynode[i - 1][j - 1]) * 0.5;
        xeta = (xnode[i][j] - xnode[i][j - 1] + xnode[i - 1][j] - xnode[i - 1][j - 1]) * 0.5;
        yeta = (ynode[i][j] - ynode[i][j - 1] + ynode[i - 1][j] - ynode[i - 1][j - 1]) * 0.5;

        q = (yeta * ug[i][j].b - xeta * ug[i][j].c);
        r = (-yxi * ug[i][j].b + xxi * ug[i][j].c);
        c = Math.sqrt(gamma * rgas * tg[i][j]);

        deltat[i][j] = safety_factor
            * 2.8284
            * a[i][j]
            /

            ((Math.abs(q) + Math.abs(r)) / ug[i][j].a + c
                * Math.sqrt(xxi * xxi + yxi * yxi + xeta * xeta
                    + yeta * yeta + 2.0
                    * Math.abs(xeta * xxi + yeta * yxi)));
      }

    /* If that's the user's choice, make it time accurate */
    if (ntime == 1) {
      mint = 100000.0;
      for (i = 1; i < imax; ++i)
        for (j = 1; j < jmax; ++j)
          if (deltat[i][j] < mint)
            mint = deltat[i][j];

      for (i = 1; i < imax; ++i)
        for (j = 1; j < jmax; ++j)
          deltat[i][j] = mint;
    }
  }

  function calculateDummyCells(localpg:Vector.<Vector.<Number>>, localtg:Vector.<Vector.<Number>>, localug:Vector.<Vector.<Statevector>>):void {
  //  print("entering calculateDummyCells");
    var c:Number;
    var jminus:Number;
    var jplus:Number;
    var s:Number;
    var rho:Number, temp:Number,temp_:Number, u:Number, v:Number;
    var scrap:Number, scrap2:Number;
    var theta:Number;
    var uprime:Number;
    var i:int, j:int;
    var norm = new Vector2();
    var tan = new Vector2();
    var u1 = new Vector2();
    uff = machff;
    jplusff = uff + 2.0 / (gamma - 1.0) * cff;
    jminusff = uff - 2.0 / (gamma - 1.0) * cff;

    for (i = 1; i < imax; ++i) {
      /* Bottom wall boundary cells */
      /* Routine checked by brute force for initial conditions, 4/9; 4:30 */
      /*
       * Routine checked by brute force for random conditions, 4/13, 4:40
       * pm
       */
      /* Construct tangent vectors */
      tan.ihat = xnode[i][0] - xnode[i - 1][0];
      tan.jhat = ynode[i][0] - ynode[i - 1][0];
      norm.ihat = -(ynode[i][0] - ynode[i - 1][0]);
      norm.jhat = xnode[i][0] - xnode[i - 1][0];

      scrap = tan.magnitude();
      tan.ihat = tan.ihat / scrap;
      tan.jhat = tan.jhat / scrap;
      scrap = norm.magnitude();
      norm.ihat = norm.ihat / scrap;
      norm.jhat = norm.jhat / scrap;

      /* now set some state variables */
      rho = localug[i][1].a;
      localtg[i][0] = localtg[i][1];
      if(isNaN(localtg[i][0]))
      {
        print("localtg is Nan for i index: "+i);
        errorCheck=true;
        return;
      }
      u1.ihat = localug[i][1].b / rho;
      u1.jhat = localug[i][1].c / rho;

      u = u1.dot(tan) + u1.dot(norm) * tan.jhat / norm.jhat;
      temp_=(tan.ihat - (norm.ihat * tan.jhat / norm.jhat));
      u = u / temp_;

      v = -(u1.dot(norm) + u * norm.ihat) / norm.jhat;

      /* And construct the new state vector */
      localug[i][0].a = localug[i][1].a;
      localug[i][0].b = rho * u;
      localug[i][0].c = rho * v;
      localug[i][0].d = rho
          * (Cv * localtg[i][0] + 0.5 * (u * u + v * v));
      localpg[i][0] = localpg[i][1];

      /* Top Wall Boundary Cells */
      /* Checked numerically for default conditions, 4/9 at 5:30 pm */
      /* Construct normal and tangent vectors */
      /* This part checked and works; it produces the correct vectors */
      tan.ihat = xnode[i][jmax - 1] - xnode[i - 1][jmax - 1];
      tan.jhat = ynode[i][jmax - 1] - ynode[i - 1][jmax - 1];
      norm.ihat = ynode[i][jmax - 1] - ynode[i - 1][jmax - 1];
      norm.jhat = -(xnode[i][jmax - 1] - xnode[i - 1][jmax - 1]);

      scrap = tan.magnitude();
      tan.ihat = tan.ihat / scrap;
      tan.jhat = tan.jhat / scrap;
      scrap = norm.magnitude();
      norm.ihat = norm.ihat / scrap;
      norm.jhat = norm.jhat / scrap;

      /* now set some state variables */
      rho = localug[i][jmax - 1].a;
      temp = localtg[i][jmax - 1];
      u1.ihat = localug[i][jmax - 1].b / rho;
      u1.jhat = localug[i][jmax - 1].c / rho;

      u = u1.dot(tan) + u1.dot(norm) * tan.jhat / norm.jhat;
      //Alex: broke this up since it was treating combination of / * / in this equation as a comment!
      temp_=(tan.ihat - (norm.ihat * tan.jhat / norm.jhat));
      u = u / temp_;

      v = -(u1.dot(norm) + u * norm.ihat) / norm.jhat;

      /* And construct the new state vector */
      localug[i][jmax].a = localug[i][jmax - 1].a;
      localug[i][jmax].b = rho * u;
      localug[i][jmax].c = rho * v;
      localug[i][jmax].d = rho * (Cv * temp + 0.5 * (u * u + v * v));
      localtg[i][jmax] = temp;
      if(isNaN(localtg[i][jmax]) || localtg[i][jmax] <0)
      {
        print("localtg["+i+"]["+jmax+"] is NaN for i:jmax: "+i+":"+jmax);
        print("temp is: "+temp);
        errorCheck=true;
        return;
      }
      localpg[i][jmax] = localpg[i][jmax - 1];
    }
    for (j = 1; j < jmax; ++j) {
      /* Inlet Boundary Cells: unchecked */
      /* Construct the normal vector; This works, 4/10, 2:00 pm */
      norm.ihat = ynode[0][j - 1] - ynode[0][j];
      norm.jhat = xnode[0][j] - xnode[0][j - 1];
      scrap = norm.magnitude();
      norm.ihat = norm.ihat / scrap;
      norm.jhat = norm.jhat / scrap;
      theta = Math.acos((ynode[0][j - 1] - ynode[0][j])
          / Math.sqrt((xnode[0][j] - xnode[0][j - 1])
              * (xnode[0][j] - xnode[0][j - 1])
              + (ynode[0][j - 1] - ynode[0][j])
              * (ynode[0][j - 1] - ynode[0][j])));

      u1.ihat = localug[1][j].b / localug[1][j].a;
      u1.jhat = localug[1][j].c / localug[1][j].a;
      uprime = u1.ihat * Math.cos(theta);
      c = Math.sqrt(gamma * rgas * localtg[1][j]);

      /* Supersonic inflow; works on the initial cond, 4/10 at 3:10 pm */
      if (uprime < -c) {
        /* Use far field conditions */
        localug[0][j].a = rhoff;
        localug[0][j].b = rhoff * uff;
        localug[0][j].c = rhoff * vff;
        localug[0][j].d = rhoff
            * (Cv * tff + 0.5 * (uff * uff + vff * vff));
        localtg[0][j] = tff;

        localpg[0][j] = pff;
      }
      /* Subsonic inflow */
      /* This works on the initial conditions 4/10 @ 2:20 pm */
      else if (uprime < 0.0) {
        /* Calculate Riemann invarients here */
        jminus = u1.ihat - 2.0 / (gamma - 1.0) * c;

        s = Math.log(pff) - gamma * Math.log(rhoff);
        v = vff;

        u = (jplusff + jminus) / 2.0;
        scrap = (jplusff - u) * (gamma - 1.0) * 0.5;

        localtg[0][j] = (1.0 / (gamma * rgas)) * scrap * scrap;

        localpg[0][j] = Math.exp(s)
            / Math.pow((rgas * localtg[0][j]), gamma);
        localpg[0][j] = Math.pow(localpg[0][j], 1.0 / (1.0 - gamma));

        /* And now: construct the new state vector */
        localug[0][j].a = localpg[0][j] / (rgas * localtg[0][j]);
        localug[0][j].b = localug[0][j].a * u;
        localug[0][j].c = localug[0][j].a * v;
        localug[0][j].d = localug[0][j].a
            * (Cv * tff + 0.5 * (u * u + v * v));
      }
      /* Other options */
      /* We should throw an exception here */
      else {
        /*
         * theta = Math.acos((ynode[0][j - 1] - ynode[0][j])
          / Math.sqrt((xnode[0][j] - xnode[0][j - 1])
              * (xnode[0][j] - xnode[0][j - 1])
              + (ynode[0][j - 1] - ynode[0][j])
              * (ynode[0][j - 1] - ynode[0][j])));
         */
        print("You have outflow at the inlet, which is not allowed. xnode[0]["+(j-1)+"] is: "+xnode[0][j - 1]+ "xnode[0]["+j+"] is: "+xnode[0][j]);
        print("ynode[0]["+(j-1)+"] is: "+ynode[0][j - 1]+ "ynode[0]["+j+"] is: "+ynode[0][j]);
        if(isNaN(c))
        {
          print("c is NaN in the else part");
          errorCheck=true;
          return;
        }else if(c=="NaN")
        {
          print("c is string NaN")
          errorCheck=true;
          return;
        }
        else
        {
          print("none of the conditions hit");
        }
        print("c is: "+c);
        print("theta is: "+theta);
        print("gamma: "+gamma);
        print("rgas: "+rgas);
        print("localtg[1]["+j+"]: "+localtg[1][j]);
        print("temp: "+temp);
        if(c==NaN)
        {
          print("c is NaN == compare");
          errorCheck=true;
          return;
        }else if(c=="NaN")
        {
          print("c is string NaN")
          errorCheck=true;
          return;
        }
        else
        {
          print("none of the conditions hit");
        }
        //print("imax is: "+imax);
        
      }

      /* Outlet Boundary Cells */
      /* Construct the normal vector; works, 4/10 3:10 pm */
      norm.ihat = ynode[0][j] - ynode[0][j - 1];
      norm.jhat = xnode[0][j - 1] - xnode[0][j];
      scrap = norm.magnitude();
      norm.ihat = norm.ihat / scrap;
      norm.jhat = norm.jhat / scrap;
      scrap = xnode[0][j - 1] - xnode[0][j];
      scrap2 = ynode[0][j] - ynode[0][j - 1];
      theta = Math.acos((ynode[0][j] - ynode[0][j - 1])
          / Math.sqrt(scrap * scrap + scrap2 * scrap2));

      u1.ihat = localug[imax - 1][j].b / localug[imax - 1][j].a;
      u1.jhat = localug[imax - 1][j].c / localug[imax - 1][j].a;
      uprime = u1.ihat * Math.cos(theta);
      c = Math.sqrt(gamma * rgas * localtg[imax - 1][j]);
      /* Supersonic outflow; works for defaults cond, 4/10: 3:10 pm */
      if (uprime > c) {
        /* Use a backward difference 2nd order derivative approximation */
        /* To set values at exit */
        localug[imax][j].a = 2.0 * localug[imax - 1][j].a
            - localug[imax - 2][j].a;
        localug[imax][j].b = 2.0 * localug[imax - 1][j].b
            - localug[imax - 2][j].b;
        localug[imax][j].c = 2.0 * localug[imax - 1][j].c
            - localug[imax - 2][j].c;
        localug[imax][j].d = 2.0 * localug[imax - 1][j].d
            - localug[imax - 2][j].d;
        localpg[imax][j] = 2.0 * localpg[imax - 1][j]
            - localpg[imax - 2][j];
        localtg[imax][j] = 2.0 * localtg[imax - 1][j]
            - localtg[imax - 2][j];
      }
      /* Subsonic Outflow; works for defaults cond, 4/10: 3:10 pm */
      else if (uprime < c && uprime > 0) {
        jplus = u1.ihat + 2.0 / (gamma - 1) * c;
        v = localug[imax - 1][j].c / localug[imax - 1][j].a;
        s = Math.log(localpg[imax - 1][j]) - gamma
            * Math.log(localug[imax - 1][j].a);

        u = (jplus + jminusff) / 2.0;
        scrap = (jplus - u) * (gamma - 1.0) * 0.5;
        localtg[imax][j] = (1.0 / (gamma * rgas)) * scrap * scrap;
        localpg[imax][j] = Math.exp(s)
            / Math.pow((rgas * localtg[imax][j]), gamma);
        localpg[imax][j] = Math.pow(localpg[imax][j],
            1.0 / (1.0 - gamma));
        rho = localpg[imax][j] / (rgas * localtg[imax][j]);

        /* And now, construct the new state vector */
        localug[imax][j].a = rho;
        localug[imax][j].b = rho * u;
        localug[imax][j].c = rho * v;
        localug[imax][j].d = rho
            * (Cv * localtg[imax][j] + 0.5 * (u * u + v * v));

      }
      /* Other cases that shouldn't have to be used. */
      else if (uprime < -c) {
        /* Supersonic inflow */
        /* Use far field conditions */
        localug[0][j].a = rhoff;
        localug[0][j].b = rhoff * uff;
        localug[0][j].c = rhoff * vff;
        localug[0][j].d = rhoff
            * (Cv * tff + 0.5 * (uff * uff + vff * vff));
        localtg[0][j] = tff;
        localpg[0][j] = pff;
      }
      /* Subsonic inflow */
      /* This works on the initial conditions 4/10 @ 2:20 pm */
      else if (uprime < 0.0) {
        /* Debug: throw exception here? */
        /* Calculate Riemann invarients here */
        jminus = u1.ihat - 2.0 / (gamma - 1.0) * c;
        s = Math.log(pff) - gamma * Math.log(rhoff);
        v = vff;

        u = (jplusff + jminus) / 2.0;
        scrap = (jplusff - u) * (gamma - 1.0) * 0.5;
        localtg[0][j] = (1.0 / (gamma * rgas)) * scrap * scrap;
        localpg[0][j] = Math.exp(s)
            / Math.pow((rgas * localtg[0][j]), gamma);
        localpg[0][j] = Math.pow(localpg[0][j], 1.0 / (1.0 - gamma));

        /* And now: construct the new state vector */
        localug[0][j].a = localpg[0][j] / (rgas * localtg[0][j]);
        localug[0][j].b = localug[0][j].a * u;
        localug[0][j].c = localug[0][j].a * v;
        localug[0][j].d = localug[0][j].a
            * (Cv * tff + 0.5 * (u * u + v * v));
      }
      /* Other Options */
      /* Debug: throw exception here? */
      else {
        print("You have inflow at the outlet, which is not allowed.");
      }
    }
    /* Do something with corners to avoid division by zero errors */
    /* What you do shouldn't matter */
    localug[0][0] = localug[1][0];
    localug[imax][0] = localug[imax][1];
    localug[0][jmax] = localug[1][jmax];
    localug[imax][jmax] = localug[imax][jmax - 1];
  }
  
  function runiters():void {
    var itercounter_:int=0;
    for (itercounter_ = 0; itercounter_ < iter; itercounter_++) {
      doIteration();
    }
  }



class Statevector {
  var a:Number; /* Storage for Statevectors */
  var b:Number;
  var c:Number;
  var d:Number;

  function Statevector():void {
    a = 0.0;
    b = 0.0;
    c = 0.0;
    d = 0.0;
  }

  /* Most of these vector manipulation routines are not used in this program */
  /* because I inlined them for speed. I leave them here because they may */
  /* be useful in the future. */
  function amvect( m:Number,  that:Statevector):Statevector {
    /* Adds statevectors multiplies the sum by scalar m */
    var answer:Statevector = new Statevector();

    answer.a = m * (this.a + that.a);
    answer.b = m * (this.b + that.b);
    answer.c = m * (this.c + that.c);
    answer.d = m * (this.d + that.d);

    return answer;
  }

  function avect(that:Statevector):Statevector {
    var answer:Statevector = new Statevector();
    /* Adds two statevectors */
    answer.a = this.a + that.a;
    answer.b = this.b + that.b;
    answer.c = this.c + that.c;
    answer.d = this.d + that.d;

    return answer;
  }

  function mvect( m:Number):Statevector {
    var answer:Statevector = new Statevector();
    /* Multiplies statevector scalar m */
    answer.a = m * this.a;
    answer.b = m * this.b;
    answer.c = m * this.c;
    answer.d = m * this.d;

    return answer;
  }

  function svect(that:Statevector):Statevector {
    var answer:Statevector = new Statevector();
    /* Subtracts vector that from this */
    answer.a = this.a - that.a;
    answer.b = this.b - that.b;
    answer.c = this.c - that.c;
    answer.d = this.d - that.d;

    return answer;
  }

  function smvect( m:Number,  that:Statevector):Statevector {
    var answer:Statevector = new Statevector();
    /* Subtracts statevector that from this and multiplies the */
    /* result by scalar m */
    answer.a = m * (this.a - that.a);
    answer.b = m * (this.b - that.b);
    answer.c = m * (this.c - that.c);
    answer.d = m * (this.d - that.d);

    return answer;
  }
}

class Vector2 {
  var ihat:Number; /* Storage for 2-D vector */

  var jhat:Number;

  function Vector2():void {
    ihat = 0.0;
    jhat = 0.0;
  }

  function magnitude():Number {
    var mag:Number;

    mag = Math.sqrt(this.ihat * this.ihat + this.jhat * this.jhat);
    return mag;
  }

  function dot( that:Vector2):Number {
    /* Calculates dot product of two 2-d vector */
    var answer:Number;

    answer = ihat * that.ihat + jhat * that.jhat;

    return answer;
  }
}
  
  
  if (CONFIG::desktop) {
      var start = new Date();
      JGFrun(0);
      var elapsed = new Date() - start;
  }
  else { // mobile
      // unable to trim this test down further
      var elapsed = 0;
  }
      if (JGFvalidate())
        print("metric time "+elapsed);
    else
        print("validation failed");
  